#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
using namespace std;
bool isprime(long long n) {
  if (n % 2 == 0) {
    return false;
  }
  for (auto i = 3; i * i <= n; i += 2) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
long long digitsum(long long n) {
  long long sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main() {
  int n, cnt = 0, r = 0;
  cin >> n;
  char a[n][n];
  for (auto i = 0; i < n; i++)
    for (auto j = 0; j < n; j++) cin >> a[i][j];
  for (auto i = 0; i < n; i++) {
    for (auto j = 0; j < n; j++) {
      cnt = 0;
      if (a[i][j] == 'C') {
        for (auto k = i + 1; k < n; k++)
          if (a[k][j] == 'C') cnt++;
        for (auto k = j + 1; k < n; k++)
          if (a[i][k] == 'C') cnt++;
      }
      r += cnt;
    }
  }
  cout << r;
}
