#include <bits/stdc++.h>
using namespace std;
const int INF = 1E9 + 7;
const int maxn = 1E6 + 5;
int main() {
  int n;
  cin >> n;
  char a[105][105];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int cur = 0;
    for (int j = 1; j <= n; j++) {
      if (a[i][j] == 'C') cur++;
    }
    ans += (cur * (cur - 1) / 2);
  }
  for (int j = 1; j <= n; j++) {
    int cur = 0;
    for (int i = 1; i <= n; i++) {
      if (a[i][j] == 'C') cur++;
    }
    ans += (cur * (cur - 1) / 2);
  }
  cout << ans;
  return 0;
}
