#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int res = 0;
  for (int i = 0; i < n; ++i) {
    int cnt = 0;
    for (int j = 0; j < n; ++j) {
      if (a[i][j] == 'C') {
        ++cnt;
      }
    }
    res += cnt * (cnt - 1) / 2;
  }
  for (int i = 0; i < n; ++i) {
    int cnt = 0;
    for (int j = 0; j < n; ++j) {
      if (a[j][i] == 'C') {
        ++cnt;
      }
    }
    res += cnt * (cnt - 1) / 2;
  }
  cout << res << '\n';
  return 0;
}
