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