#include #include #include #define rep(i,n) for(i=0;i<(int)(n);i++) using namespace std; typedef long long ll; typedef unsigned long long ull; int n; int main(){ int i,j,na1=0,na2=0; scanf("%d",&n); vector row(n,0),col(n,0); string str; const int NIL=-n; rep(i,n){ cin>>str; rep(j,n){ if(str[j]=='A'){ row[i]++; col[j]++; if(i==j)na1++; if(j==n-1-i)na2++; }else if(str[j]=='B'){ row[i]=NIL; col[j]=NIL; if(i==j)na1=NIL; if(j==n-1-i)na2=NIL; } } } j=(na1==n-1)+(na2==n-1); rep(i,n)j+=(row[i]==n-1)+(col[i]==n-1); printf("%d\n",j); return 0; }