#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<char> > v;
  v.resize(n);
  for (int i = 0; i < n; i++) v[i].resize(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> v[i][j];
    }
  }
  long long answ = 0;
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      if (v[i][j] == 'C') cnt++;
    }
    answ += cnt * (cnt - 1) / 2;
  }
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      if (v[j][i] == 'C') cnt++;
    }
    answ += cnt * (cnt - 1) / 2;
  }
  cout << answ;
  return 0;
}
