#include <bits/stdc++.h>
using namespace std;
long long n, a[300], b[300], z;
char f;
int main() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      cin >> f;
      if (f == 'C') {
        z += a[i];
        a[i]++;
        z += b[j];
        b[j]++;
      }
    }
  }
  cout << z;
  return 0;
}
