#include <bits/stdc++.h>
using namespace std;
long long n, an = 0, x = 0;
char a[200][200];
int main() {
  cin >> n;
  for (int(i) = 0; i < (n); i++) {
    x = 0;
    for (int(j) = 0; j < (n); j++) {
      cin >> a[i][j];
      if (a[i][j] == 'C') x++;
    }
    an += x * (x - 1) / 2;
  }
  for (int(j) = 0; j < (n); j++) {
    x = 0;
    for (int(i) = 0; i < (n); i++)
      if (a[i][j] == 'C') x++;
    an += x * (x - 1) / 2;
  }
  cout << an;
}
