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