#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string cake[n];
  int row[n], column[n];
  memset(row, 0, sizeof(row));
  memset(column, 0, sizeof(column));
  for (int i = 0; i < n; i++) {
    cin >> cake[i];
    for (int j = 0; j < cake[i].length(); j++) {
      if (cake[i][j] == 'C') row[i]++;
    }
  }
  for (int j = 0; j < n; j++) {
    for (int i = 0; i < n; i++) {
      if (cake[i][j] == 'C') column[j]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (row[i] > 1) {
      ans += (row[i] * (row[i] - 1)) / 2;
    }
    if (column[i] > 1) {
      ans += (column[i] * (column[i] - 1)) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
