#include <bits/stdc++.h>
using namespace std;
int combin(int c) {
  int ans = 0;
  for (int i = c - 1; i >= 1;) {
    ans += i;
    i--;
  }
  return ans;
}
int main() {
  int const maxx = 105;
  int n;
  cin >> n;
  int rc, cc;
  rc = cc = 0;
  int ans = 0;
  char arr[maxx][maxx];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> arr[i][j];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (arr[i][j] == 'C') rc++;
      if (arr[j][i] == 'C') cc++;
    }
    ans += combin(rc) + combin(cc);
    cc = rc = 0;
  }
  cout << ans << endl;
  return 0;
}
