#include <bits/stdc++.h>
int n;
char map[105][105];
int row[105], col[105];
int main() {
  while (scanf("%d", &n) != EOF) {
    memset(row, 0, sizeof(row));
    memset(col, 0, sizeof(col));
    for (int i = 0; i < n; i++) scanf("%s", map[i]);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (map[i][j] == 'C') {
          row[i]++;
          col[j]++;
        }
      }
    }
    long long int res = 0;
    for (int i = 0; i < n; i++) {
      res += row[i] * (row[i] - 1) / 2;
    }
    for (int i = 0; i < n; i++) {
      res += col[i] * (col[i] - 1) / 2;
    }
    printf("%I64d\n", res);
  }
  return 0;
}
