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