#include <bits/stdc++.h>
using namespace std;
void PD() {
  cout.precision(18);
  cout << fixed;
}
void NPT() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
}
int n, i, j, k, ans;
string s[105];
int main() {
  cin >> n;
  for (i = 0; i < n; ++i) cin >> s[i];
  for (i = 0; i < n; ++i) {
    k = 0;
    for (j = 0; j < n; ++j)
      if (s[i][j] == 'C') ++k;
    ans = ans + (k * (k - 1)) / 2;
  }
  for (i = 0; i < n; ++i) {
    k = 0;
    for (j = 0; j < n; ++j)
      if (s[j][i] == 'C') ++k;
    ans = ans + (k * (k - 1)) / 2;
  }
  cout << ans;
}
