#include <bits/stdc++.h>
using namespace std;
const int DEBUG = 0;
namespace defs {
int read() {
  int aa, bb = 1, ch;
  while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-')
    ;
  ch == '-' ? aa = 0, bb = -1 : aa = ch - '0';
  while (ch = getchar(), ch >= '0' && ch <= '9') aa = aa * 10 + ch - '0';
  return aa * bb;
}
const unsigned int rand_x = 1401010315;
const unsigned int rand_y = 1000000019;
unsigned int rand_cur;
unsigned int rand_int() { return rand_cur = rand_cur * rand_x + rand_y; }
const int inf = 1071026353;
const int mod = 1000000007;
const int modx = 998244353;
const int maxn = 100010;
}  // namespace defs
namespace lightningwork {
using namespace defs;
int n, cnt[400];
char str[200];
void work() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    scanf("%s", str + 1);
    for (int j = 1; j <= n; ++j) {
      if (str[j] == 'C') {
        ++cnt[i];
        ++cnt[j + n];
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= 2 * n; ++i) {
    ans += cnt[i] * (cnt[i] - 1) / 2;
  }
  printf("%d\n", ans);
}
}  // namespace lightningwork
int main() {
  if (0)
    freopen(
        "work"
        ".in",
        "r", stdin),
        freopen(
            "work"
            ".out",
            "w", stdout);
  lightningwork::work();
  if (0) fclose(stdin), fclose(stdout);
  return 0;
}
