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