#include <bits/stdc++.h>
using namespace std;
set<long long>::iterator it;
vector<long long>::iterator it1;
struct stc {
  int fir, sc;
} input[1000];
bool comp(stc a, stc b) { return a.sc < b.sc; }
template <class T>
inline T BM(T p, T e, T M) {
  long long ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T MDINV(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T PW(T p, T e) {
  long long ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p);
    p = (p * p);
  }
  return (T)ret;
}
template <class T>
string NTS(T Number) {
  stringstream ss;
  ss << Number;
  return ss.str();
}
template <class T>
T stringtonumber(const string &Text) {
  istringstream ss(Text);
  T result;
  return ss >> result ? result : 0;
}
int main() {
  int n, i, j, k, sm, ans, sm1;
  char c[110][110];
  while (cin >> n) {
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        cin >> c[i][j];
      }
    }
    ans = 0;
    for (i = 0; i < n; i++) {
      sm = 0;
      sm1 = 0;
      for (j = 0; j < n; j++) {
        if (c[i][j] == 'C') sm++;
        if (c[j][i] == 'C') sm1++;
      }
      if (sm >= 2) {
        sm -= 1;
        sm = sm * (sm + 1);
        sm /= 2;
        ans += sm;
      }
      sm = sm1;
      if (sm >= 2) {
        sm -= 1;
        sm = sm * (sm + 1);
        sm /= 2;
        ans += sm;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
