#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, z, x, k, l, s = 0, y, c = 0, i, j;
  cin >> n;
  char a[n][n];
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  for (i = 0; i < n; i++) {
    c = 0;
    for (j = 0; j < n; j++) {
      if (a[i][j] == 'C') c++;
    }
    s += (c * (c - 1)) / 2;
  }
  for (j = 0; j < n; j++) {
    c = 0;
    for (i = 0; i < n; i++) {
      if (a[i][j] == 'C') c++;
    }
    s += (c * (c - 1)) / 2;
  }
  cout << s << endl;
  return 0;
}
