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