#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j, p, q, cnt, k, cnt1;
  char s[105][105], ch;
  while (cin >> n) {
    getchar();
    p = 0;
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= n; j++) {
        cin >> ch;
        s[i][j] = ch;
      }
    }
    for (i = 1; i <= n; i++) {
      cnt = 0;
      cnt1 = 0;
      for (j = 1; j <= n; j++) {
        if (s[i][j] == 'C') cnt++;
        if (s[j][i] == 'C') cnt1++;
      }
      p += (cnt * (cnt - 1)) / 2;
      p += (cnt1 * (cnt1 - 1)) / 2;
    }
    cout << p << endl;
  }
  return 0;
}
