#include <bits/stdc++.h>
using namespace std;
int row[100], column[100];
int main() {
  int n, result = 0;
  cin >> n;
  char a[n][n];
  int i, i2;
  for (i = 0; i < n; i++) {
    for (i2 = 0; i2 < n; i2++) {
      cin >> a[i][i2];
      if (a[i][i2] == 'C') {
        result = result + row[i];
        row[i] = row[i] + 1;
        result = result + column[i2];
        column[i2] = column[i2] + 1;
      }
    }
  }
  cout << result;
}
