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