#000252

Aleks & Andy

As the ultimate challenge, your coaches gave you a matrix of N * N letters. What is the maximal number of names of your coaches you can find such that they don't overlap.

The names can be read only left to right or top to bottom. The letter capitalization doesn't matter.

The coaches names are Aleks and Andy.



InputThe first line contains an integer N (1 <= N <= 30). The next
N lines contain the letters of the matrix.


OutputOutput one integer - the maximal number of names you can find such that they don't overlap.


Input:5
alekS
lxxxx
exxxx
Kxxxx
sxxxx

Output:1


Input:6
xxxxxA
xxxxxn
xxxaxD
xxandy
xandyx
AndYxx

Output:3

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.