#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  char arr[n + 2][n + 2];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> arr[i][j];
    }
  }
  int row = 0, ans = 0;
  for (int i = 1; i <= n; i++) {
    row = 0;
    for (int j = 1; j <= n; j++) {
      if (arr[i][j] == 'C') row++;
    }
    ans += ((row * (row - 1)) / 2);
    row = 0;
    for (int j = 1; j <= n; j++) {
      if (arr[j][i] == 'C') row++;
    }
    ans += ((row * (row - 1)) / 2);
  }
  cout << ans;
}
