Time limit
2s
Memory limit
128 MB
For two people A and B, A is a 2-friend of B if A and B are direct friends, or if there exists a person C who is friends with both A and B. The most famous person is the person with the greatest number of 2-friends.
Given the friendship relations, write a program that prints the number of 2-friends of the most famous person.
Friendship is bidirectional, and a person is not friends with themself.
The first line contains the number of people N. N is a positive integer not greater than 50.
Each of the next N lines contains a length-N string describing friendship relations. In the i-th string, the j-th character is Y if person i and person j are friends, and the letter N otherwise.
Print the number of 2-friends of the most famous person on one line.