#include <bits/stdc++.h>
using namespace std;
int n;
char a[105][105];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) scanf("%s", a[i]);
  int perechi = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      if (a[i][j] == 'C') {
        for (int k = j + 1; k < n; ++k)
          if (a[i][k] == 'C') ++perechi;
        for (int k = i + 1; k < n; ++k)
          if (a[k][j] == 'C') ++perechi;
      }
    }
  cout << perechi << endl;
  return 0;
}
