#include <bits/stdc++.h>
using namespace std;
const int N = 100;
int n;
char s[N][N];
void input() {
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> s[i][j];
}
void output() {
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int a = 0, b = 0;
    for (int j = 0; j < n; j++) {
      if (s[i][j] == 'C') a++;
      if (s[j][i] == 'C') b++;
    }
    ans += (a * (a - 1) / 2) + (b * (b - 1) / 2);
  }
  cout << ans << endl;
}
int main() {
  input(), output();
  return 0;
}
