#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, n, m, cnt;
  char a[1000][1000];
  while (cin >> n) {
    long ans = 0;
    for (i = 0; i < n; i++) {
      cin >> a[i];
      cnt = 0;
      for (j = 0; j < n; j++) {
        if (a[i][j] == 'C') cnt++;
      }
      if (cnt >= 2) ans += ((cnt - 1) * cnt) >> 1;
    }
    for (i = 0; i < n; i++) {
      cnt = 0;
      for (j = 0; j < n; j++) {
        if ('C' == a[j][i]) cnt++;
      }
      if (cnt >= 2) ans += ((cnt - 1) * cnt) >> 1;
    }
    cout << ans << endl;
  }
  return 0;
}
