#include <bits/stdc++.h>
using namespace std;
long long operation(long long a) {
  long long h = (a * (a - 1)) / 2;
  return h;
}
int main() {
  long long a;
  cin >> a;
  char matriz[a][a];
  for (long long i = 0; i < a; i++) {
    for (long long j = 0; j < a; j++) {
      char g;
      cin >> g;
      matriz[i][j] = g;
    }
  }
  long long rsp = 0;
  for (long long i = 0; i < a; i++) {
    long long s = 0;
    for (long long j = 0; j < a; j++) {
      if (matriz[i][j] == 'C') {
        s++;
      }
    }
    rsp = rsp + operation(s);
  }
  for (long long i = 0; i < a; i++) {
    long long s = 0;
    for (long long j = 0; j < a; j++) {
      if (matriz[j][i] == 'C') {
        s++;
      }
    }
    rsp = rsp + operation(s);
  }
  cout << rsp << endl;
}
