BOMBONI
문제
Little Ivan is bored at math class so he decided to play popular game called "Bomboni". At the beginning all fields of N×N square board contain candies (not necessarily of same color). When its his turn player should swap two neighbouring (up, down, left or right) candies of different color and then pick some sequence (in row or column) of same color candies which he will take and eat.
Initial board configuration is given, help Ivan and write a program which will calculate maximal number of candies he can win in the first move.
입력
In the first line of standard input there is one integer N (3 ≤ N ≤ 50), board dimensions.
In next N lines initial board configuration is given, j-th character in i-th row denotes color of candy at square (i, j) : C (red), P (blue), Z (green), Y (yellow). It will always be possible to make first move.
출력
In the first and only line of standard output print the maximal number of candies Ivan can win in the first move.
힌트
Second test example explanation: in first row we see sequence PPPP, so swapping any two candies in other rows first row remain unchanged so Ivan can take it.
Third test example explanation: swapping candies Y and C in 4th row Ivan gets sequence CCCC in first column.
예제
예제 1
3 CCP CCP PPC
3
예제 2
4 PPPP CYZY CCPY PPCC
4
예제 3
5 YCPZY CYZZP CCPPP YCYZC CPPZZ
4