#include <bits/stdc++.h>
using namespace std;
long long int fact(long long int n) {
  long long int ans = 1;
  for (long long int i = 1; i <= n; i++) {
    ans *= i;
  }
  return ans;
}
long sum(long long ara[], long n) {
  double sum = 0;
  for (int i = 0; i < n; i++) {
    sum += ara[i];
  }
  return sum;
}
int main() {
  int n;
  cin >> n;
  vector<string> str;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    str.push_back(s);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int row = 0;
    for (int j = 0; j < n; j++) {
      if (str[i][j] == 'C') {
        row++;
      }
    }
    ans += (((row) * (row - 1)) / 2);
  }
  for (int i = 0; i < n; i++) {
    int col = 0;
    for (int j = 0; j < n; j++) {
      if (str[j][i] == 'C') {
        col++;
      }
    }
    ans += (((col) * (col - 1)) / 2);
  }
  cout << ans << endl;
}
