#include <bits/stdc++.h>
const long double pi = 3.14159265359;
const long double Exp = 2.71828182846;
using namespace std;
void Prepere_streams() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
long long a[101] = {0};
int main() {
  int n;
  long long c = 0;
  char f;
  long long res = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    c = 0;
    for (int j = 0; j < n; ++j) {
      cin >> f;
      if (f == 'C') {
        ++a[j];
        ++c;
      }
    }
    res += (c * (c - 1)) / 2;
  }
  for (int i = 0; i < n; ++i) res += (a[i] * (a[i] - 1) / 2);
  cout << res;
  cin >> n;
}
