N = int(input()) S = [input() for _ in range(N)] ans = 0 for i in range(N): if S[i].count('A') == N - 1 and S[i].count('.') == 1: ans += 1 for i in range(N): ca = 0 cd = 0 for j in range(N): if S[j][i] == 'A': ca += 1 if S[j][i] == '.': cd += 1 if ca == N - 1 and cd == 1: ans += 1 ca1 = 0 cd1 = 0 ca2 = 0 cd2 = 0 for i in range(N): if S[i][i] == 'A': ca1 += 1 if S[i][i] == '.': cd1 += 1 if S[i][N - 1 - i] == 'A': ca2 += 1 if S[i][N - 1 - i] == '.': cd2 += 1 if ca1 == N - 1 and cd1 == 1: ans += 1 if ca2 == N - 1 and cd2 == 1: ans += 1 print(ans)