#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector A(n); int ans = 0; for(int y = 0; y < n; y++){ cin >> A[y]; int a = 0, b = 0; for(int x = 0; x < n; x++){ a += A[y][x] == 'A'; b += A[y][x] == 'B'; } ans += (a == n - 1 && b == 0); } for(int x = 0; x < n; x++){ int a = 0, b = 0; for(int y = 0; y < n; y++){ a += A[y][x] == 'A'; b += A[y][x] == 'B'; } ans += (a == n - 1 && b == 0); } int a = 0, b = 0; for(int y = 0; y < n; y++){ a += A[y][y] == 'A'; b += A[y][y] == 'B'; } ans += (a == n - 1 && b == 0); a = 0, b = 0; for(int y = 0; y < n; y++){ a += A[y][n - 1 - y] == 'A'; b += A[y][n - 1 - y] == 'B'; } ans += (a == n - 1 && b == 0); cout << ans << '\n'; }