#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> a) {
  return o << a.first << ' ' << a.second;
}
template <typename A, typename B>
istream& operator>>(istream& o, pair<A, B>& a) {
  return o >> a.first >> a.second;
}
const int mod = 1e9 + 7, abc = 864197532, N = 504, K = 111;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s[n];
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    int cnt = count(s[i].begin(), s[i].end(), 'C');
    ans += cnt * (cnt - 1) / 2;
  }
  for (int i = 0; i < n; ++i) {
    int cnt = 0;
    for (int j = 0; j < n; ++j) cnt += s[j][i] == 'C';
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
}
