#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  int n, RES = 0;
  cin >> n;
  vector<vector<char> > A(n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      char tmp;
      cin >> tmp;
      A[i].push_back(tmp);
    }
  for (int i = 0; i < n; i++) {
    int k = 0;
    for (int j = 0; j < n; j++) {
      if (A[i][j] == 'C') k++;
    }
    RES += ((k - 1) * k) / 2;
  }
  for (int j = 0; j < n; j++) {
    int k = 0;
    for (int i = 0; i < n; i++) {
      if (A[i][j] == 'C') k++;
    }
    RES += ((k - 1) * k) / 2;
  }
  cout << RES;
  return 0;
}
