#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char **s;
  s = new char *[n];
  int countDub = 0, countC = 0;
  for (int i = 0; i < n; i++) {
    s[i] = new char[n];
    for (int j = 0; j < n; j++) cin >> s[i][j];
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (s[i][j] == 'C') {
        for (int k = i + 1; k < n; k++)
          if (s[k][j] == 'C') countC++;
        for (int k = j + 1; k < n; k++)
          if (s[i][k] == 'C') countC++;
      }
  cout << countC;
  return 0;
}
