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