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