#include <bits/stdc++.h>
using namespace std;
string a[110];
long long col[110], row[110];
long long Fact(long long n) {
  if (n == 0) {
    return 1;
  }
  return n * Fact(n - 1);
}
int main() {
  long long i, j, k, n, cnt_c = 0, cnt_r = 0, ans = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      for (k = j + 1; k < n; k++) {
        if (a[i][j] == 'C' && a[i][k] == 'C') ans++;
        if (a[j][i] == 'C' && a[k][i] == 'C') ans++;
      }
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (a[i][j] == 'C') {
        row[i]++;
        col[j]++;
      }
    }
  }
  for (i = 0; i < n; i++) {
    if (row[i] == 2) {
      cnt_r++;
    }
  }
  for (i = 0; i < n; i++) {
    if (row[i] > 2) {
      cnt_r += Fact(row[i]) / (Fact(2) * Fact(row[i] - 2));
    }
  }
  for (i = 0; i < n; i++) {
    if (col[i] == 2) {
      cnt_c++;
    }
  }
  for (i = 0; i < n; i++) {
    if (col[i] > 2) {
      cnt_c += Fact(col[i]) / (Fact(2) * Fact(col[i] - 2));
    }
  }
  cout << ans;
  return 0;
}
