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