#include <bits/stdc++.h>
using namespace std;
string f[111];
int n;
int ans = 0;
int temp = 0;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) cin >> f[i];
  for (int i = 0; i < n; i++) {
    temp = 0;
    for (int j = 0; j < n; j++)
      if (f[i][j] == 'C') temp++;
    ans += temp * (temp - 1) / 2;
  }
  for (int i = 0; i < n; i++) {
    temp = 0;
    for (int j = 0; j < n; j++)
      if (f[j][i] == 'C') temp++;
    ans += temp * (temp - 1) / 2;
  }
  cout << ans << endl;
}
