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