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