#include <bits/stdc++.h>
using namespace std;
char a[110][110];
int main() {
  int n;
  cin >> n;
  string s;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    for (int j = 1; j <= n; j++) a[i][j] = s[j - 1];
  }
  for (int i = 1; i <= n; i++) {
    int row = 0;
    for (int j = 1; j <= n; j++) {
      if (a[i][j] == 'C') row++;
    }
    ans += (row * (row - 1)) / 2;
  }
  for (int j = 1; j <= n; j++) {
    int col = 0;
    for (int i = 1; i <= n; i++) {
      if (a[i][j] == 'C') col++;
    }
    ans += (col * (col - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}
