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