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