#include <bits/stdc++.h>
using namespace std;
int fact(int n) {
  if (n == 0) {
    return 1;
  }
  return n * fact(n - 1);
}
int main() {
  int n, t = 0, r;
  char c;
  cin >> n;
  vector<int> v(n, 0);
  for (int i = 0; i < n; i++) {
    r = 0;
    for (int j = 0; j < n; j++) {
      cin >> c;
      if (c == 'C') {
        t += r;
        r++;
        v[j]++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    int r = 0;
    while (r != v[i]) {
      t += r;
      r++;
    }
  }
  cout << t << endl;
}
