#include using namespace std; using ll = long long; #define rep(i, n) for(int i = 0; i < n; i++) int main() { int N; cin >> N; vector s(N); rep(i, N) cin >> s[i]; int ans = 0; rep(i, N) { int a = 0, d = 0; rep(j, N) { if(s[i][j] == 'A') a++; if(s[i][j] == '.') d++; } if(a == N - 1 && d == 1) ans++; } rep(j, N) { int a = 0, d = 0; rep(i, N) { if(s[i][j] == 'A') a++; if(s[i][j] == '.') d++; } if(a == N - 1 && d == 1) ans++; } int a = 0, d = 0; rep(i, N) { if(s[i][i] == 'A') a++; if(s[i][i] == '.') d++; } if(a == N - 1 && d == 1) ans++; a = 0; d = 0; rep(i, N) { if(s[N - 1 - i][i] == 'A') a++; if(s[N - 1 - i][i] == '.') d++; } if(a == N - 1 && d == 1) ans++; cout << ans << endl; }