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