#include <bits/stdc++.h>
using namespace std;
int main() {
  signed long long int N;
  char Mass[100][100];
  int I[100] = {0};
  int J[100] = {0};
  cin >> N;
  char t;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> t;
      Mass[i][j] = t;
      if (Mass[i][j] == 'C') {
        I[i]++;
        J[j]++;
      }
    }
  }
  signed long long int S(0);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < I[i]; j++) S += j;
    for (int j = 0; j < J[i]; j++) S += j;
  }
  cout << S;
  return 0;
}
