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