#pragma GCC optimize("Ofast") #include using namespace std; typedef long long int ll; typedef unsigned long long int ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } inline double time() { return static_cast(chrono::duration_cast(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector s(n); for (int i = 0; i < n; ++i) { cin >> s[i]; } int res = 0; for (int i = 0; i < n; ++i) { int a = 0, b = 0; for (int j = 0; j < n; ++j) { if (s[i][j] == 'A') a += 1; else if (s[i][j] == '.') b += 1; } if (a == n-1 and b) res += 1; } for (int i = 0; i < n; ++i) { int a = 0, b = 0; for (int j = 0; j < n; ++j) { if (s[j][i] == 'A') a += 1; else if (s[j][i] == '.') b += 1; } if (a == n-1 and b) res += 1; } { int a = 0, b = 0; for (int j = 0; j < n; ++j) { if (s[j][j] == 'A') a += 1; else if (s[j][j] == '.') b += 1; } if (a == n-1 and b) res += 1; } { int a = 0, b = 0; for (int j = 0; j < n; ++j) { if (s[n-1-j][j] == 'A') a += 1; else if (s[n-1-j][j] == '.') b += 1; } if (a == n-1 and b) res += 1; } cout << res << endl; }