#include <bits/stdc++.h>
using namespace std;
char ch[101][101];
int main(void) {
  int n, r, c, sum = 0;
  cin >> n;
  r = c = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> ch[i][j];
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (ch[i][j] == 'C') ++r;
    }
    if (r >= 2) {
      --r;
      sum += r * (r + 1) / 2;
    }
    r = 0;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (ch[j][i] == 'C') ++c;
    }
    if (c >= 2) {
      --c;
      sum += c * (c + 1) / 2;
    }
    c = 0;
  }
  cout << sum;
  return 0;
}
