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