#include <bits/stdc++.h>
using namespace std;
const int maxn = 111;
long long hang[maxn], lie[maxn], G[maxn][maxn], N;
int main() {
  char c;
  scanf("%I64d", &N);
  memset(hang, 0, sizeof(hang));
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      c = getchar();
      while (c != '.' && c != 'c' && c != 'C') c = getchar();
      if (c == '.')
        G[i][j] = 0;
      else
        G[i][j] = 1;
      hang[i] += G[i][j];
      lie[j] += G[i][j];
    }
  }
  long long sum = 0;
  for (int i = 1; i <= N; ++i) {
    if (hang[i] > 0) sum += hang[i] * (hang[i] - 1);
    if (lie[i] > 0) sum += lie[i] * (lie[i] - 1);
  }
  printf("%I64d\n", sum / 2);
  return 0;
}
