#include <bits/stdc++.h>
using namespace std;
int cal(int n) { return (n * (n - 1)) / 2; }
int n, col[105], row[105];
string s[105];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; j < n; j++) {
      if (s[i][j] == 'C') {
        row[i]++;
        col[j]++;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += cal(row[i]) + cal(col[i]);
  }
  printf("%d", ans);
  return 0;
}
