n=int(input()) a=[input() for _ in range(n)] c=0 for i in range(n): A=0;B=0 for j in range(n): if a[i][j]=='A': A+=1 elif a[i][j]=='B': B+=1 if A==n-1 and B==0: c+=1 for i in range(n): A=0;B=0 for j in range(n): if a[j][i]=='A': A+=1 elif a[j][i]=='B': B+=1 if A==n-1 and B==0: c+=1 A=0;B=0 for i in range(n): if a[i][i]=='A': A+=1 elif a[i][i]=='B': B+=1 if A==n-1 and B==0: c+=1 A=0;B=0 for i in range(n): if a[i][n-1-i]=='A': A+=1 elif a[i][n-1-i]=='B': B+=1 if A==n-1 and B==0: c+=1 print(c)