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