#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
char s[105][105];
int cal(int x) { return x * (x - 1) / 2; }
void fmain() {
  scanf("%d", &n);
  for (int(i) = 1; (i) <= (int)(n); (i)++) scanf("%s", s[i] + 1);
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    m = 0;
    for (int(j) = 1; (j) <= (int)(n); (j)++)
      if (s[i][j] == 'C') m++;
    k += cal(m);
  }
  for (int(j) = 1; (j) <= (int)(n); (j)++) {
    m = 0;
    for (int(i) = 1; (i) <= (int)(n); (i)++)
      if (s[i][j] == 'C') m++;
    k += cal(m);
  }
  printf("%d\n", k);
}
int main() {
  fmain();
  return 0;
}
