#include <bits/stdc++.h>
using namespace std;
int main() {
  string currs = "", prevs = "";
  int n;
  cin >> n;
  vector<vector<char> > cake(n, vector<char>(n, ' '));
  long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> cake[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    long cCount = 0;
    for (int j = 0; j < n; j++) {
      if (cake[i][j] == 'C') cCount++;
    }
    ans += ((cCount) * (cCount - 1)) / 2;
  }
  for (int i = 0; i < n; i++) {
    long cCount = 0;
    for (int j = 0; j < n; j++) {
      if (cake[j][i] == 'C') cCount++;
    }
    ans += ((cCount) * (cCount - 1)) / 2;
  }
  cout << ans << endl;
}
