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