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