#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, x;
  cin >> k;
  char c[k][k];
  int count = 0;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++) {
      cin >> c[i][j];
    }
  }
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k - 1; j++) {
      for (int m = j + 1; m < k; m++) {
        if (c[i][j] == 'C' && c[i][m] == 'C') count++;
      }
    }
  }
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k - 1; j++) {
      for (int m = j + 1; m < k; m++) {
        if (c[j][i] == 'C' && c[m][i] == 'C') count++;
      }
    }
  }
  cout << count;
  return 0;
}
