#include <bits/stdc++.h>
using namespace std;
void FastIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
int main() {
  FastIO();
  long long int n, ans = 0;
  char ch;
  cin >> n;
  vector<long long int> c1(n, 0), c2(n, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> ch;
      if (ch == 'C') {
        c1[i]++;
        c2[j]++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    ans += ((c1[i] * (c1[i] - 1)) / 2);
    ans += ((c2[i] * (c2[i] - 1)) / 2);
  }
  cout << ans << '\n';
  return 0;
}
