#include using namespace std; int main() { int N, Ans = 0, AC = 0, BC = 0; cin >> N; vector S(N); for (string &T : S) cin >> T; for (int i = 0; i < N; i++) { AC = 0, BC = 0; for (int j = 0; j < N; j++) { if (S.at(i).at(j) == 'A') AC++; if (S.at(i).at(j) == 'B') BC++; } if (AC == N - 1 && BC == 0) Ans++; } for (int i = 0; i < N; i++) { AC = 0, BC = 0; for (int j = 0; j < N; j++) { if (S.at(j).at(i) == 'A') AC++; if (S.at(j).at(i) == 'B') BC++; } if (AC == N - 1 && BC == 0) Ans++; } AC = 0, BC = 0; for (int i = 0; i < N; i++) { if (S.at(i).at(i) == 'A') AC++; if (S.at(i).at(i) == 'B') BC++; } if (AC == N - 1 && BC == 0) Ans++; AC = 0, BC = 0; for (int i = 0; i < N; i++) { if (S.at(N - i - 1).at(i) == 'A') AC++; if (S.at(N - i - 1).at(i) == 'B') BC++; } if (AC == N - 1 && BC == 0) Ans++; cout << Ans << endl; }