#include <bits/stdc++.h>
int main() {
  int a, b, c;
  char d;
  int ZA[101], ZB[101], ZC[101];
  ZA[0] = ZA[1] = 0;
  for (a = 2; a < 101; ++a) ZA[a] = a + ZA[a - 1] - 1;
  for (a = 0; a < 101; ++a) ZB[a] = ZC[a] = 0;
  scanf("%d\n", &a);
  for (b = 0; b < a; ++b) {
    for (c = 0; c < a; ++c) {
      scanf("%c", &d);
      if (d == 'C') {
        ZB[b] += 1;
        ZC[c] += 1;
      }
    }
    scanf("\n");
  }
  c = 0;
  for (b = 0; b < a; ++b) c += ZA[ZB[b]] + ZA[ZC[b]];
  printf("%d\n", c);
  return 0;
}
