#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> row(n);
  vector<int> col(n);
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    for (int x = 0; x < s.size(); ++x) {
      if (s[x] == 'C') {
        col[i]++;
        row[x]++;
      }
    }
  }
  for (int i = 0; i < row.size(); ++i) {
    sum += row[i] * (row[i] - 1) / 2;
  }
  for (int i = 0; i < col.size(); ++i) {
    sum += col[i] * (col[i] - 1) / 2;
  }
  cout << sum << endl;
  return 0;
}
