#include <bits/stdc++.h>
using namespace std;
int per(int &n) {
  int ans = 1;
  return ans / 2;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  char a;
  vector<char> v;
  vector<vector<char>> vv;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a;
      v.push_back(a);
    }
    vv.push_back(v);
    v.clear();
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int row = 0, col = 0;
    for (int j = 0; j < n; j++) {
      if (vv[i][j] == 'C') row++;
      if (vv[j][i] == 'C') col++;
    }
    ans += ((row)*max(row - 1, 0) / 2 + (col)*max(col - 1, 0) / 2);
  }
  cout << ans << "\n";
  return 0;
}
