#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  vector<string> a(n);
  for (long long int i = 0; i < n; i++) cin >> a[i];
  long long int happy = 0;
  for (long long int r = 0; r < n; r++) {
    long long int count = 0;
    for (long long int c = 0; c < n; c++) {
      if (a[r][c] == 'C') count++;
    }
    happy += (count * (count - 1) * 0.5);
  }
  for (long long int c = 0; c < n; c++) {
    long long int count = 0;
    for (long long int r = 0; r < n; r++) {
      if (a[r][c] == 'C') count++;
    }
    happy += (count * (count - 1) * 0.5);
  }
  cout << happy << endl;
}
