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