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