#include <bits/stdc++.h>
using namespace std;
int Combinations(int n, int k) {
  if (k > n) return 0;
  int r = 1;
  for (int d = 1; d <= k; ++d) {
    r *= n--;
    r /= d;
  }
  return r;
}
int main() {
  int n;
  cin >> n;
  char A[n][n];
  int count1;
  int count2 = 0;
  for (int i = 0; i < n; ++i) {
    count1 = 0;
    for (int j = 0; j < n; ++j) {
      cin >> A[i][j];
      if (A[i][j] == 'C') {
        ++count1;
      }
    }
    if (count1 > 1) {
      count2 += Combinations(count1, 2);
    }
  }
  for (int i = 0; i < n; ++i) {
    count1 = 0;
    for (int j = 0; j < n; ++j) {
      if (A[j][i] == 'C') {
        ++count1;
      }
    }
    if (count1 > 1) {
      count2 += Combinations(count1, 2);
    }
  }
  cout << count2;
  return 0;
}
