N = int(input()) S = [input() for _ in range(N)] ans = 0 for r in range(N): if S[r].count('A') == N-1: ans += 1 for c in range(N): cnt = 0 for r in range(N): if S[r][c] == 'A': cnt += 1 if cnt == N-1: ans += 1 cnt = 0 for d in range(N): if S[d][d] == 'A': cnt += 1 if cnt == N-1: ans += 1 cnt = 0 for d in range(N): if S[d][N-d-1] == 'A': cnt += 1 if cnt == N-1: ans += 1 print(ans)