#include <bits/stdc++.h>
size_t solve(const std::vector<std::string>& c) {
  const size_t n = c.size();
  size_t count = 0;
  for (size_t i = 0; i < n; ++i) {
    for (size_t j = 0; j < n; ++j) {
      for (size_t k = j + 1; k < n; ++k) {
        if (c[i][j] == 'C' && c[i][k] == 'C') ++count;
        if (c[j][i] == 'C' && c[k][i] == 'C') ++count;
      }
    }
  }
  return count;
}
int main() {
  size_t n;
  std::cin >> n;
  std::vector<std::string> c(n);
  for (size_t i = 0; i < n; ++i) std::cin >> c[i];
  std::cout << solve(c) << '\n';
  return 0;
}
