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