#include using namespace std; #include using namespace atcoder; #define rep(i,n) for (int i = 0; i < (n); ++i) using ld = long double; using ll = long long; template bool chmax(T &a, T b) { if(a bool chmin(T &a, T b) { if(a>b) { a = b; return true; } return false; } int N; string S[100]; int main() { cin >> N; rep(i,N) cin >> S[i]; int ans = 0; rep(i,N) { map mp; rep(j,N) mp[S[i][j]]++; if(mp['A']==N-1) ans++; } rep(j,N) { map mp; rep(i,N) mp[S[i][j]]++; if(mp['A']==N-1) ans++; } map mp; rep(i,N) mp[S[i][i]]++; if(mp['A']==N-1) ans++; mp.clear(); rep(i,N) mp[S[i][N-1-i]]++; if(mp['A']==N-1) ans++; cout << ans << endl; }