#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long N = 100000;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}
template <typename first, typename second>
ostream &operator<<(ostream &os, const pair<first, second> &p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename first, typename second>
ostream &operator<<(ostream &os, const map<first, second> &v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << it->first << " = " << it->second;
  }
  return os << "]";
}
void slow() {}
void fast() {}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  char grid[n][n];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) cin >> grid[i][j];
  }
  long long res = 0;
  for (long long i = 0; i < n; i++) {
    long long cnt = 0;
    for (long long j = 0; j < n; j++) {
      if (grid[i][j] == 'C') cnt++;
    }
    res += ((cnt * (cnt - 1)) / 2);
  }
  for (long long i = 0; i < n; i++) {
    long long cnt = 0;
    for (long long j = 0; j < n; j++) {
      if (grid[j][i] == 'C') cnt++;
    }
    res += ((cnt * (cnt - 1)) / 2);
  }
  cout << res << "\n";
  return 0;
}
