#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e2 + 2;
int N;
char grid[MAX][MAX];
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%s", grid[i]);
  long long ans = 0;
  for (int r = 0; r < N; r++)
    for (int c = 0; c < N; c++) {
      if (grid[r][c] == 'C')
        for (int i = c + 1; i < N; i++) {
          if (grid[r][i] == 'C') ans++;
        }
      if (grid[r][c] == 'C')
        for (int i = r + 1; i < N; i++) {
          if (grid[i][c] == 'C') ans++;
        }
    }
  printf("%lld\n", ans);
}
