#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5;
int row[MAX];
int col[MAX];
int main() {
  int N;
  cin >> N;
  char X[N + 99][N + 99];
  for (int A = 1; A <= N; A++)
    for (int B = 1; B <= N; B++) {
      cin >> X[A][B];
      if (X[A][B] == 'C') row[A]++, col[B]++;
    }
  int ans = 0;
  for (int A = 1; A <= N; A++)
    for (int B = 1; B <= N; B++) {
      if (X[A][B] == 'C') ans += row[A] + col[B] - 2;
    }
  cout << ans / 2;
  return 0;
}
