#include <bits/stdc++.h>
using namespace std;
template <class X, class Y>
void minimize(X &x, const Y &y) {
  if (x > y) x = y;
}
template <class X, class Y>
void maximize(X &x, const Y &y) {
  if (x < y) x = y;
}
char a[111][111];
int n;
void process(void) {
  scanf("%d", &n);
  for (int i = (1), _b = (n); i <= _b; i = i + 1) scanf("%s", a[i] + 1);
  vector<pair<int, int> > cell;
  for (int i = (1), _b = (n); i <= _b; i = i + 1)
    for (int j = (1), _b = (n); j <= _b; j = j + 1)
      if (a[i][j] == 'C') cell.push_back(make_pair(i, j));
  int res = 0;
  for (int i = 0, _n = (cell.size()); i < _n; i = i + 1)
    for (int j = (i + 1), _b = ((int)cell.size() - 1); j <= _b; j = j + 1)
      if (cell[i].first == cell[j].first || cell[i].second == cell[j].second)
        res++;
  printf("%d\n", res);
}
int main(void) {
  process();
  return 0;
}
