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