#include <bits/stdc++.h>
int main() {
  int n1, n2 = 0, n3 = 0;
  std::cin >> n1;
  std::vector<std::vector<char>> v1(n1, std::vector<char>(n1));
  for (int i = 0; i < n1; i++)
    for (int j = 0; j < n1; j++) std::cin >> v1[i][j];
  for (int i = 0; i < n1; i++) {
    for (int j = 0; j < n1; j++) {
      if (v1[i][j] == 'C') n2++;
    }
    n3 += n2 * (n2 - 1) / 2;
    n2 = 0;
  }
  for (int i = 0; i < n1; i++) {
    for (int j = 0; j < n1; j++) {
      if (v1[j][i] == 'C') n2++;
    }
    if (n2 != 0) n3 += n2 * (n2 - 1) / 2;
    n2 = 0;
  }
  std::cout << n3;
}
