#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (auto x : v[i]) {
      if (x == 'C') {
        cnt++;
      }
    }
    ans += cnt * (cnt - 1) / 2;
  }
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      if (v[j][i] == 'C') {
        cnt++;
      }
    }
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
}
