8 WA , 2 TLE
#include<bits/stdc++.h>
using namespace std;
inline long long rd(){//quick read
long long x=0;bool ntv=false;char c=getchar();
while((c<'0'||c>'9')&&c!='-')c=getchar();
if(c=='-')ntv=true;else x=(c^48);c=getchar();
while(c>='0'&&c<='9'){x=x*10+(c^48);c=getchar();}
return ntv?-x:x;
}
int main(){
//read
long long n=rd(),m,count=0;
char w[n][n];
for(int i=0;i<n;getchar()+i++)
for(int j=0;j<n;j++)
w[i][j]=getchar();
//count
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
if(w[i][j]=='W')
for(int ii=0;ii<=i;ii++)
for(int jj=0;jj<=j;jj++)
if(w[ii][jj]=='W'){
m=1;
for(int k=ii;k<=i&&m==1;k++)
for(int l=jj;l<=j&&m==1;l++)
if(w[k][l]=='B')
m=0;
if(m==1)
count++;
}
//print
cout<<count;
return 0;
}