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