#include <bits/stdc++.h>
int main(void) {
  long int N, i, j, *row, *col;
  char c;
  scanf("%ld\n", &N);
  row = (long int*)malloc(sizeof(long int) * N);
  col = (long int*)malloc(sizeof(long int) * N);
  for (i = 0; i < N; i++) {
    row[i] = 0;
    col[i] = 0;
  }
  for (i = 0; i < N; i++) {
    for (j = 0; j < N; j++) {
      scanf("%c", &c);
      if (c == 'C') {
        col[j]++;
        row[i]++;
      }
    }
    scanf("%c", &c);
  }
  long int ans = 0;
  for (i = 0; i < N; i++) {
    ans = ans + (row[i] * (row[i] - 1)) / 2;
    ans = ans + (col[i] * (col[i] - 1)) / 2;
  }
  printf("%ld", ans);
  return 0;
}
