#include using namespace std; using ll = long long; int N; string S[110]; int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> N; for(int i = 0;i < N;i++)cin >> S[i]; int ans = 0; for(int i = 0;i < N;i++){ int cnta = 0, cntb = 0; for(int j = 0;j < N;j++){ cnta += S[i][j] == 'A'; cntb += S[i][j] == 'B'; } ans += (cnta == N - 1 && cntb == 0); } for(int j = 0;j < N;j++){ int cnta = 0, cntb = 0; for(int i = 0;i < N;i++){ cnta += S[i][j] == 'A'; cntb += S[i][j] == 'B'; } ans += (cnta == N - 1 && cntb == 0); } { int cnta = 0, cntb = 0; for(int i = 0;i < N;i++){ cnta += S[i][i] == 'A'; cntb += S[i][i] == 'B'; } ans += (cnta == N - 1 && cntb == 0); } { int cnta = 0, cntb = 0; for(int i = 0;i < N;i++){ cnta += S[i][N - 1 - i] == 'A'; cntb += S[i][N - 1 - i] == 'B'; } ans += (cnta == N - 1 && cntb == 0); } cout << ans << endl; return 0; }