#include<bits/stdc++.h>
using namespace std;
int q[200][200],mat[200][200];
int main(){
int n;
cin>>n;
long long ans=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
char x;
cin>>x;
if(x=='W') mat[i][j]=0;
else mat[i][j]=1;
q[i][j]=q[i-1][j]+q[i][j-1]-q[i-1][j-1]+mat[i][j];
}
}for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(mat[i][j]==0){
for(int i1=1;i1<=i;i1++){
for(int j1=1;j1<=j;j1++){
if(i1==i&&j1==j) continue;
if(mat[i][j]==mat[i1][j1]){
ans++;
}
}
}
}
}
}cout<<ans;
}