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