#include <bits/stdc++.h>
long long int fact(long long int x) {
  if (x == 0)
    return 1;
  else
    return x * fact(x - 1);
}
long long int create(int n) {
  int i, j, r, x;
  long long int c;
  char A[n][n];
  x = fact(2);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      scanf(" %c", &A[i][j]);
    }
  }
  c = 0;
  for (i = 0; i < n; i++) {
    r = 0;
    for (j = 0; j < n; j++) {
      if (A[i][j] == 'C') {
        r++;
      }
    }
    if (r >= 2) {
      c = c + (r * (r - 1)) / 2;
    }
  }
  for (j = 0; j < n; j++) {
    r = 0;
    for (i = 0; i < n; i++) {
      if (A[i][j] == 'C') {
        r++;
      }
    }
    if (r >= 2) {
      c = c + (r * (r - 1)) / 2;
    }
  }
  return (c);
}
int main() {
  long long int m;
  int n;
  scanf(" %d", &n);
  m = create(n);
  printf("%I64d\n", m);
  return 0;
}
