#include using namespace std; #if __has_include() #include using namespace atcoder; #endif #ifdef LOCAL #include "algo/debug.hpp" #else #define debug(...) void(0) #endif using ll = long long; using ld = long double; const ll linf=(1LL<<60) - 1; const int inf=(1LL<<30) - 1; #define len(obj) int(obj.size()) #define overload4(a,b,c,d,name,...) name #define overload5(a,b,c,d,e,name,...) name #define rep1(n) for(ll _=0;_=0;--_) #define rrep2(i,n) for(ll i=n-1;i>=0;--i) #define rrep3(i,a,b) for(ll i=b-1;i>=a;--i) #define rrep4(i,a,b,c) for(ll i=(a)+((b)-(a)-1)/(c)*(c);i>=(a);i-=c) #define rrep(...) overload4(__VA_ARGS__,rrep4,rrep3,rrep2,rrep1)(__VA_ARGS__) #define each1(i,a) for(auto&&i:a) #define each2(x,y,a) for(auto&&[x,y]:a) #define each3(x,y,z,a) for(auto&&[x,y,z]:a) #define each4(w,x,y,z,a) for(auto&&[w,x,y,z]:a) #define each(...) overload5(__VA_ARGS__,each4,each3,each2,each1)(__VA_ARGS__) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define vec(type,name,...) vector name(__VA_ARGS__) #define vv(type,name,h,...) vector name(h,vector(__VA_ARGS__)) #define vvv(type,name,h,w,...) vector name(h,vector(w,vector(__VA_ARGS__))) #define vvvv(type, name, h, w, n, ...) vector>>> name(h, vector>>(w, vector>(n, vector(__VA_ARGS__)))) struct Setting{ Setting(){ cin.tie(nullptr)->sync_with_stdio(0); fixed(cout).precision(12); } }Setting; //----------------------------------- int main() { int N; cin >> N; vector S(N); rep(i, N) cin >> S[i]; vector Ra(N, 0), Ca(N, 0), Da(2, 0); vector Rd(N, 0), Cd(N, 0), Dd(2, 0); rep(i, N) { rep(j, N) { Ra[i] += (S[i][j] == 'A'); Ca[i] += (S[j][i] == 'A'); if(i + j == N - 1 && S[i][j] == 'A') Da[0]++; if(i == j && S[i][j] == 'A') Da[1]++; Rd[i] += (S[i][j] == '.'); Cd[i] += (S[i][j] == '.'); if(i + j == N - 1 && S[i][j] == '.') Dd[0]++; if(i == j && S[i][j] == '.') Dd[1]++; } } int ans = 0; rep(i, N) ans += (Ra[i] == N - 1 && Rd[i] == 1); rep(i, N) ans += (Ca[i] == N - 1 && Cd[i] == 1); rep(i, 2) ans += (Da[i] == N - 1 && Dd[i] == 1); cout << ans << endl; }