#include #include using namespace std; using namespace atcoder; using ll = long long; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; #define rep(i,a,b) for(int i = a; i < b; ++i) #define rrep(i,a,b) for(int i = a; i >= b; --i) #define all(x) (x).begin(),(x).end() templatebool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; } templatebool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; } const int MOD = 998244353; int main(){ int n; cin >> n; vector s(n); rep(i,0,n)cin >> s[i]; int ans = 0; rep(i,0,n){ if(count(all(s[i]),'A') == n-1 && count(all(s[i]),'.') == 1) ans++; } vector t(n); rep(i,0,n){ rep(j,0,n){ t[i].push_back(s[j][i]); } } rep(i,0,n){ if(count(all(t[i]),'A') == n-1 && count(all(t[i]),'.') == 1) ans++; } string u; rep(i,0,n){ rep(j,i,n){ u.push_back(s[i][j]); break; } } if(count(all(u),'A') == n-1 && count(all(u),'.') == 1) ans++; vector w(n); w = s; rep(i,0,n){ reverse(all(w[i])); } string v; rep(i,0,n){ rep(j,i,n){ v.push_back(w[i][j]); break; } } if(count(all(v),'A') == n-1 && count(all(v),'.') == 1) ans++; cout << ans << endl; return 0; }