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