#include <bits/stdc++.h>
using namespace std;
int fact(int n) {
  if (n == 1 || n == 0) return 1;
  return n * fact(n - 1);
}
int C(int n, int k) { return (n * (n - 1)) / 2; }
int main() {
  char** A;
  int n;
  int sum = 0;
  cin >> n;
  A = new char*[n];
  for (int i = 0; i < n; i++) {
    A[i] = new char[n + 1];
    cin >> A[i];
  }
  for (int i = 0; i < n; ++i) {
    int s1 = 0;
    int s2 = 0;
    for (int j = 0; j < n; ++j) {
      s1 += (A[i][j] == 'C');
      s2 += (A[j][i] == 'C');
    }
    sum += s1 > 1 ? C(s1, 2) : 0;
    sum += s2 > 1 ? C(s2, 2) : 0;
  }
  cout << sum << endl;
  return 0;
}
