#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 4;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  string s[n];
  int ct = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      if (s[i][j] == 'C') {
        cnt++;
      }
    }
    ct = ct + (cnt * (cnt - 1)) / 2;
  }
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      if (s[j][i] == 'C') {
        cnt++;
      }
    }
    ct = ct + (cnt * (cnt - 1)) / 2;
  }
  cout << ct;
  return 0;
}
