#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, r[105], c[105];
  memset(r, 0, sizeof(r));
  memset(c, 0, sizeof(c));
  char ch;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> ch;
      if (ch == 'C') {
        r[i]++;
        c[j]++;
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (c[i] >= 2) ans += c[i] * (c[i] - 1) / 2;
    if (r[i] >= 2) ans += r[i] * (r[i] - 1) / 2;
  }
  cout << ans;
  return 0;
}
