#include <bits/stdc++.h>
using namespace std;
int a[101], b[101];
long long dat[1001];
long long modex(long long x) {}
int main() {
  int n;
  dat[2] = 1;
  cin >> n;
  for (int i = 3; i <= n; i++) {
    dat[i] = dat[i - 1] + i - 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      char dum;
      cin >> dum;
      if (dum == 'C') {
        a[j]++;
        b[i]++;
      }
    }
  }
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] > 1) sum += dat[a[i]];
    if (b[i] > 1) sum += dat[b[i]];
  }
  cout << sum << endl;
}
