#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> str(n);
  for (int i = 0; i < n; i++) cin >> str[i];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int c = 0;
    for (int j = 0; j < n; j++) {
      if (str[i][j] == 'C') c++;
    }
    ans += ((c - 1) * (c) / 2);
  }
  for (int j = 0; j < n; j++) {
    int c = 0;
    for (int i = 0; i < n; i++) {
      if (str[i][j] == 'C') c++;
    }
    ans += ((c - 1) * (c) / 2);
  }
  cout << ans;
}
