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