#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  string s[n];
  for (int i = 0; i < n; i++) cin >> s[i];
  long long row, col;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    row = col = 0;
    for (int j = 0; j < n; j++) {
      if (s[i][j] == 'C') row++;
      if (s[j][i] == 'C') col++;
    }
    ans += row * (row - 1) / 2 + col * (col - 1) / 2;
  }
  cout << ans << "\n";
  return 0;
}
