#include <bits/stdc++.h>
using namespace std;
char str[105][105];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> str[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      if (str[i][j] == 'C') {
        ans += cnt;
        cnt++;
      }
    }
    int ctn = 0;
    for (int j = 0; j < n; j++) {
      if (str[j][i] == 'C') {
        ans += ctn;
        ctn++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
