#include <bits/stdc++.h>
using namespace std;
int arrange(int a, int c) {
  if (a == 2) return 1;
  if (a == 3) return 3;
  int temp = c;
  int multipul = a * (a - 1);
  return multipul / 2;
}
int main() {
  int pairs = 0;
  char cake[100][100] = {};
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> cake[i][j];
  for (int i = 0; i < n; i++) {
    int num = 0;
    for (int j = 0; j < n; j++)
      if (cake[i][j] == 'C') num++;
    if (num > 1) pairs += arrange(num, 2);
  }
  for (int i = 0; i < n; i++) {
    int num = 0;
    for (int j = 0; j < n; j++)
      if (cake[j][i] == 'C') num++;
    if (num > 1) pairs += arrange(num, 2);
  }
  cout << pairs << endl;
  return 0;
}
