#include <bits/stdc++.h>
using namespace std;
bool equalTo(double a, double b) {
  if (fabs(a - b) <= 1e-9) return true;
  return false;
}
bool notEqual(double a, double b) {
  if (fabs(a - b) > 1e-9) return true;
  return false;
}
bool lessThan(double a, double b) {
  if (a + 1e-9 < b) return true;
  return false;
}
bool lessThanEqual(double a, double b) {
  if (a < b + 1e-9) return true;
  return false;
}
bool greaterThan(double a, double b) {
  if (a > b + 1e-9) return true;
  return false;
}
bool greaterThanEqual(double a, double b) {
  if (a + 1e-9 > b) return true;
  return false;
}
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  return GCD(b, a % b);
}
long long LCM(long long a, long long b) { return a * b / GCD(a, b); }
long long POW(long long a, long long p) {
  long long res = 1, x = a;
  while (p) {
    if (p & 1) res = (res * x);
    x = (x * x);
    p >>= 1;
  }
  return res;
}
long long DP[105][4];
long long nCr(int n, int r) {
  if (r > n) return 0;
  if (n == r) return DP[n][r] = 1;
  if (r == 0) return DP[n][r] = 1;
  if (r == 1) return DP[n][r] = (long long)n;
  if (DP[n][r]) return DP[n][r];
  return DP[n][r] = nCr(n - 1, r) + nCr(n - 1, r - 1);
}
int N, K;
char Mat[105][105];
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%s", Mat[i]);
  long long res = 0;
  for (int r = 0; r < N; r++) {
    long long cnt = 0;
    for (int c = 0; c < N; c++) {
      if (Mat[r][c] == 'C') cnt++;
    }
    res += nCr(cnt, 2);
  }
  for (int r = 0; r < N; r++) {
    int cnt = 0;
    for (int c = 0; c < N; c++) {
      if (Mat[c][r] == 'C') cnt++;
    }
    res += nCr(cnt, 2);
  }
  cout << res << endl;
}
