#include <bits/stdc++.h>
using namespace std;
const int N = 0;
int n, k, x, t, m;
string s;
vector<int> v;
int row[100], col[100];
int main() {
  cin >> n;
  memset(row, 0, sizeof row);
  memset(col, 0, sizeof col);
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < n; j++) {
      if (s[j] == 'C') {
        col[j]++;
        row[i]++;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += (row[i] * (row[i] - 1)) / 2;
    ans += (col[i] * (col[i] - 1)) / 2;
  }
  cout << ans;
  return 0;
}
