#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s[101];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s[i];
  int row[101] = {0}, col[101] = {0};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (s[i][j] == 'C') {
        row[i]++;
        col[j]++;
      }
    }
  }
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    if (row[i] >= 3) {
      long long ans1 = row[i] * (row[i] - 1) / 2;
      sum += ans1;
    } else if (row[i] == 2)
      sum++;
    if (col[i] >= 3) {
      long long ans2 = col[i] * (col[i] - 1) / 2;
      sum += ans2;
    } else if (col[i] == 2)
      sum++;
  }
  cout << sum << endl;
  return 0;
}
