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