#include <bits/stdc++.h>
using namespace std;
int main() {
  int x = 0, n, a = 1, b = 0;
  long long m = 0;
  long long y = 1;
  cin >> n;
  char a1[1002][1200];
  int b1[10000];
  int b2[10000];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> a1[j][i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a1[j][i] == 'C') {
        b1[x] = i;
        b2[x] = j;
        x++;
      }
    }
  }
  for (int i = 0; i < x; i++) {
    for (int j = i + 1; j < x; j++) {
      if (b1[i] == b1[j] || b2[i] == b2[j]) {
        m++;
      }
    }
  }
  cout << m;
}
