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