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