#include using namespace std; #define all(v) (v).begin(),(v).end() #define pb(a) push_back(a) #define rep(i, n) for(int i=0;i> n; vector s(n); rep(i, n) { cin >> s[i]; } ll ans = 0; rep(i, n) { ll sum = 0; bool ng = false; rep(j, n) { sum += (s[i][j] == 'A'); ng |= (s[i][j] == 'B'); } if(sum == n - 1 and !ng) ans ++; } rep(j, n) { ll sum = 0; bool ng = false; rep(i, n) { sum += (s[i][j] == 'A'); ng |= (s[i][j] == 'B'); } if(sum == n - 1 and !ng) ans ++; } { ll sum = 0; bool ng = false; rep(i, n) { sum += (s[i][i] == 'A'); ng |= (s[i][i] == 'B'); } if(sum == n - 1 and !ng) ans ++; } { ll sum = 0; bool ng = false; rep(i, n) { sum += (s[i][n - i - 1] == 'A'); ng |= (s[i][n - i - 1] == 'B'); } if(sum == n - 1 and !ng) ans ++; } cout << ans << endl; return 0; }