#include <bits/stdc++.h>
using namespace std;
bool f(vector<int> a, vector<int> b) {
  if (a[0] - a[1] < b[0] - b[1]) {
    return 1;
  }
  return 0;
}
int main() {
  long long n, ans = 0;
  cin >> n;
  vector<int> v1(n), v(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      char c;
      cin >> c;
      if (c == 'C') {
        v[i]++;
        v1[j]++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    ans += v[i] * (v[i] - 1) / 2;
    ans += v1[i] * (v1[i] - 1) / 2;
  }
  cout << ans << endl;
}
