#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
const int mod = 1e9 + 7;
const int eps = 1e9 - 11;
const int inf = 2e9;
long long n, ans;
long long st[N], sr[N];
char c;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> c;
      if (c == 'C') st[i]++, sr[j]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    ans += (st[i] * (st[i] - 1)) / 2;
    ans += (sr[i] * (sr[i] - 1)) / 2;
  }
  cout << ans;
}
