#include <bits/stdc++.h>
using namespace std;
int choose(int n, int k) {
  if (k == 0) return 1;
  return (n * choose(n - 1, k - 1)) / k;
}
int main() {
  int n;
  cin >> n;
  char c;
  int fila[n + 1], columna[n + 1];
  fill(fila, fila + n + 1, 0);
  fill(columna, columna + n + 1, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> c;
      if (c == 'C') {
        fila[i]++;
        columna[j]++;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n + 1; i++) {
    ans += choose(fila[i], 2);
    ans += choose(columna[i], 2);
  }
  cout << ans << endl;
  return 0;
}
