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