#include <bits/stdc++.h>
using namespace std;
const int N = 102;
char s[N][N];
int n;
int main() {
  int i, j, k;
  long long res = 0;
  cin >> n;
  for (i = 0; i < n; i++) cin >> s[i];
  for (i = 0; i < n; i++) {
    k = 0;
    for (j = 0; j < n; j++)
      if (s[i][j] == 'C') k++;
    res += k * (k - 1) / 2;
  }
  for (j = 0; j < n; j++) {
    k = 0;
    for (i = 0; i < n; i++)
      if (s[i][j] == 'C') k++;
    res += k * (k - 1) / 2;
  }
  cout << res << endl;
  return 0;
}
