#include <bits/stdc++.h>
using namespace std;
int sumx[105];
int sumy[105];
char table[105][105];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%s", table[i]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (table[i][j] == 'C') {
        sumx[i]++;
        sumy[j]++;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (table[i][j] == 'C') {
        ans = ans + sumx[i] - 1;
        ans = ans + sumy[j] - 1;
      }
    }
  }
  printf("%d\n", ans / 2);
  return 0;
}
