#include <bits/stdc++.h>
using namespace std;
long long n, a, b;
int main() {
  char s[105][105];
  long long ans = 0;
  long long n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%s", s[i]);
  }
  for (int i = 0; i < n; i++) {
    int r = 0, c = 0;
    for (int j = 0; j < n; j++) {
      if (s[i][j] == 'C') r++;
      if (s[j][i] == 'C') c++;
    }
    ans += (r * (r - 1)) / 2 + (c * (c - 1)) / 2;
  }
  cout << ans << endl;
}
