#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> receipe;
  string temp;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    receipe.emplace_back(temp);
  }
  int c = 0, use = 0;
  for (int i = 0; i < n; i++) {
    use = count(receipe[i].begin(), receipe[i].end(), 'C');
    c += use * (use - 1) / 2;
  }
  for (int i = 0; i < n; i++) {
    use = 0;
    for (int j = 0; j < n; j++)
      if (receipe[j][i] == 'C') use++;
    c += use * (use - 1) / 2;
  }
  cout << c;
  return 0;
}
