#include <bits/stdc++.h>
using namespace std;
long long int pow(long long int x, long long int y, long long int m) {
  long long int res = 1;
  x = x % m;
  while (y > 0) {
    if (y & 1) res = ((res % m) * (x % m)) % m;
    y = y >> 1;
    x = ((x % m) * (x % m)) % m;
  }
  return res % m;
}
template <typename Arg1>
void ZZ(const char* name, Arg1&& arg1) {
  std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
const long long int INF = 0xFFFFFFFFFFFFFFFL;
int clz(unsigned long long N) { return N ? 64 - __builtin_clzll(N) : -INF; }
clock_t time_p = clock();
void abhigyan10() {
  time_p = clock() - time_p;
  cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
long long int seed;
mt19937 rng(seed = chrono::steady_clock::now().time_since_epoch().count());
inline long long int rnd(long long int l = 0, long long int r = INF) {
  return uniform_int_distribution<long long int>(l, r)(rng);
}
const long long int mod = 1000000007;
long long int modinv(long long int x) { return pow(x, mod - 2, mod); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, i, j;
  cin >> n;
  long long int ans = 0;
  vector<int> r(n + 1), c(n + 1);
  char x;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      cin >> x;
      if (x == 'C') {
        r[i]++;
        c[j]++;
      }
    }
  }
  for (i = 0; i < n; i++) {
    ans += r[i] * (r[i] - 1) / 2 + c[i] * (c[i] - 1) / 2;
  }
  cout << ans;
  return 0;
}
