#include <bits/stdc++.h>
const int MAXN = 100;
char cake[MAXN][MAXN + 1];
int main() {
  int n;
  scanf("%d", &n);
  for (int row = 0; row < n; ++row) {
    scanf("%s", cake[row]);
  }
  int pairs = 0;
  for (int i = 0; i < n; ++i) {
    int inRow = 0, inCol = 0;
    for (int j = 0; j < n; ++j) {
      inRow += cake[i][j] == 'C';
      inCol += cake[j][i] == 'C';
    }
    pairs += inRow * (inRow - 1) / 2 + inCol * (inCol - 1) / 2;
  }
  printf("%d", pairs);
  return 0;
}
