from collections import defaultdict N = int(input()) S = [list(input()) for _ in range(N)] ans = 0 for i in range(N): D = defaultdict(int) for j in range(N): D[S[i][j]] += 1 if "A" in D and D["A"] == N-1 and "." in D and D["."] == 1: ans += 1 for j in range(N): D = defaultdict(int) for i in range(N): D[S[i][j]] += 1 if "A" in D and D["A"] == N-1 and "." in D and D["."] == 1: ans += 1 D = defaultdict(int) for i in range(N): D[S[i][i]] += 1 if "A" in D and D["A"] == N-1 and "." in D and D["."] == 1: ans += 1 D = defaultdict(int) for i in range(N): D[S[i][N-i-1]] += 1 if "A" in D and D["A"] == N-1 and "." in D and D["."] == 1: ans += 1 print(ans)