#include <bits/stdc++.h>
template <typename T>
using Vector2D = std::vector<std::vector<T>>;
template <typename T>
using Vector3D = std::vector<Vector2D<T>>;
using PairInt = std::pair<int, int>;
using PairInt64 = std::pair<int64_t, int64_t>;
using MapInt = std::map<int, int>;
using MMapInt = std::multimap<int, int>;
using MMapInt64 = std::multimap<int64_t, int64_t>;
using UMapIntString = std::unordered_map<int, std::string>;
using SetInt = std::set<int>;
using SetPairInt64 = std::set<PairInt64>;
using VectorInt = std::vector<int>;
using VectorInt2D = Vector2D<int>;
using VectorInt64 = std::vector<int64_t>;
using VectorUInt64 = std::vector<uint64_t>;
using VectorInt642D = Vector2D<int64_t>;
using VectorChar = std::vector<char>;
using VectorChar2D = Vector2D<char>;
using VectorString = std::vector<std::string>;
using QueuePairInt = std::queue<PairInt>;
using QueueInt = std::queue<int>;
using VectorPairInt = std::vector<PairInt>;
using VectorPairInt64 = std::vector<PairInt64>;
using VectorPairInt2D = Vector2D<PairInt>;
using SetInt = std::set<int>;
using MSetInt = std::multiset<int>;
using UMapChar = std::map<char, int>;
using ListInt = std::list<int>;
using VectorListInt = std::vector<ListInt>;
using VectorDouble = std::vector<double>;
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  std::cin >> n;
  VectorString tt(n);
  for (auto& t : tt) {
    std::cin >> t;
  }
  int64_t ans = 0;
  for (int i = 0; i < n; ++i) {
    int64_t r = 0;
    int64_t c = 0;
    for (int j = 0; j < n; ++j) {
      if (tt[i][j] == 'C') {
        ++r;
      }
      if (tt[j][i] == 'C') {
        ++c;
      }
    }
    ans += r * (r - 1) / 2;
    ans += c * (c - 1) / 2;
  }
  std::cout << ans;
  return 0;
}
