#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-9;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 1100000;
const int maxm = 2e3 + 100;
inline int read() {
  char ch = getchar();
  int x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m;
int num_puts;
char num[200][200];
int main() {
  n = read();
  for (int i = 0; i < n; ++i) {
    scanf("%s", num[i]);
  }
  int number = 0;
  for (int i = 0; i < n; ++i) {
    number = 0;
    for (int j = 0; j < n; ++j) {
      if (num[i][j] == 'C') {
        ++number;
      }
    }
    num_puts += number * (number - 1) / 2;
  }
  for (int i = 0; i < n; ++i) {
    number = 0;
    for (int j = 0; j < n; ++j) {
      if (num[j][i] == 'C') {
        ++number;
      }
    }
    num_puts += number * (number - 1) / 2;
  }
  cout << num_puts << endl;
  return 0;
}
