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