#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  long long n;
  vector<string> a(105);
  vector<long long> b(105, 0), c(105, 0);
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    for (long long j = 0; j < n; j++)
      if (a[i][j] == 'C') {
        b[i]++;
        c[j]++;
      }
  }
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    sum += b[i] * (b[i] - 1) / 2 + c[i] * (c[i] - 1) / 2;
  }
  cout << sum;
}
