#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; } } rep(i,0,n){ if(count(all(u),'A') == n-1 && count(all(u),'.') == 1) ans++; } string v; rrep(i,n-1,0){ rrep(j,i,0){ v.push_back(s[i][j]); break; } } rep(i,0,n){ if(count(all(v),'A') == n-1 && count(all(v),'.') == 1) ans++; } cout << ans << endl; return 0; }