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