#include <bits/stdc++.h>
using namespace std;
int row[101], col[101];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      char c;
      cin >> c;
      if (c == 'C') {
        row[i]++;
        col[j]++;
      }
    }
  }
  int ians = 0;
  for (int i = 0; i < n; i++) {
    if (row[i] > 0) ians = ians + (row[i] * (row[i] - 1)) / 2;
    if (col[i] > 0) ians = ians + (col[i] * (col[i] - 1)) / 2;
  }
  cout << ians << endl;
  return 0;
}
