#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];
    }
  }
  vector<int> v;
  for (int i = 0; i < n; i++) {
    short counter = 0;
    short counter1 = 0;
    for (int j = 0; j < n; j++) {
      if (arr[i][j] == 'C') {
        counter++;
      }
      if (arr[j][i] == 'C') {
        counter1++;
      }
    }
    v.push_back(counter);
    v.push_back(counter1);
  }
  int sum = 0;
  for (int i = 0; i < v.size(); i++) {
    if (v[i] != 0 && v[i] != 1) {
      sum = sum + (v[i] * (v[i] - 1)) / 2;
    }
  }
  cout << sum;
}
