#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, x = 0, m;
  cin >> n;
  long long int p[n], q[n];
  char a[n][n];
  for (int i = 0; i < n; i++) {
    m = 0;
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'C') m++;
    }
    p[i] = m;
  }
  for (int i = 0; i < n; i++) {
    m = 0;
    for (int j = 0; j < n; j++) {
      if (a[j][i] == 'C') m++;
    }
    q[i] = m;
  }
  sort(p, p + n);
  sort(q, q + n);
  m = 0;
  for (int i = 0; i < n; i++) {
    if (p[i] >= 2) m = m + ((p[i] * (p[i] - 1)) / 2);
    if (q[i] >= 2) m = m + ((q[i] * (q[i] - 1)) / 2);
  }
  cout << m;
}
