#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(false);
  int i, f, g;
  int n;
  cin >> n >> ws;
  string a[n + 10];
  for (i = 0; i <= n - 1; i += 1) {
    cin >> a[i];
  }
  long long int result = 0;
  for (i = 0; i <= n - 1; i += 1) {
    int chocolateInRow = 0;
    int chocolateInCol = 0;
    for (f = 0; f <= n - 1; f += 1) {
      if (a[i][f] == 'C') ++chocolateInRow;
      if (a[f][i] == 'C') ++chocolateInCol;
    }
    if (chocolateInRow >= 2)
      result += chocolateInRow * (chocolateInRow - 1) / 2;
    if (chocolateInCol >= 2)
      result += chocolateInCol * (chocolateInCol - 1) / 2;
  }
  cout << result;
  return 0;
}
