#include <bits/stdc++.h>
using namespace std;
int lin[200], col[200], i, l, c, n, s;
char x;
int main() {
  cin >> n;
  for (l = 1; l <= n; l++) {
    for (c = 1; c <= n; c++) {
      cin >> x;
      if (x == 'C') {
        lin[l]++;
        col[c]++;
      }
    }
  }
  for (i = 1; i <= n; i++)
    s = s + lin[i] * (lin[i] - 1) / 2 + col[i] * (col[i] - 1) / 2;
  cout << s;
  return 0;
}
