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