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