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