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