#include <bits/stdc++.h>
int col[110];
int row[110];
char o[110];
int main() {
  int i, j, n;
  int ans = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s", o);
    for (j = 0; j < n; j++) {
      if (o[j] == 'C') {
        col[i]++;
        row[j]++;
      }
    }
  }
  for (i = 0; i < n; i++) {
    ans += (col[i] - 1) * col[i] / 2;
    ans += (row[i] - 1) * row[i] / 2;
  }
  printf("%d", ans);
  return 0;
}
