#include <bits/stdc++.h>
using namespace std;
int c[105], l[105];
long long ans;
int n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      char ch;
      cin >> ch;
      if (ch == 'C') {
        ++l[i];
        ++c[j];
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (l[i] > 1) {
      ans += ((l[i] * (l[i] - 1)) / 2);
    }
    if (c[i] > 1) {
      ans += ((c[i] * (c[i] - 1)) / 2);
    }
  }
  cout << ans << '\n';
  return 0;
}
