#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char arr[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> arr[i][j];
    }
  }
  pair<int, int> p[n * n];
  int in = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (arr[i][j] == 'C') {
        p[in] = make_pair(i, j);
        in++;
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < in; i++) {
    for (int j = i + 1; j < in; j++) {
      if (p[i].first == p[j].first || p[i].second == p[j].second) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}
