#include <bits/stdc++.h>
using namespace std;
long long fact(int x) {
  long long ans = 0;
  while (x > 0) {
    ans += x;
    x--;
  }
  return ans;
}
int main() {
  int n;
  cin >> n;
  vector<vector<char> > a(n, vector<char>(n));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> a[i][j];
  vector<int> ansi(n);
  vector<int> ansj(n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (a[i][j] == 'C') {
        ansi[i]++;
        ansj[j]++;
      }
  long long count = 0;
  long long ans = 0;
  for (int i = 0; i < n; i++) count += fact(ansi[i] - 1);
  ans += count;
  count = 0;
  for (int i = 0; i < n; i++) count += fact(ansj[i] - 1);
  ans += count;
  cout << ans;
  return 0;
}
