#include <bits/stdc++.h>
using namespace std;
long long n;
long long i = 0, j = 0, k = 0;
long long a = 0, b = 0, c = 0;
char ch;
string s;
string rr = "RR";
string gg = "GG";
string bb = "BB";
vector<long long> v;
set<char> se;
long long dateb[1000][1000];
long long row[1000];
long long col[1000];
long long date[1000];
long long sum = 0;
long long t;
map<long long, long long> m;
long long solve() {
  for (long long i = (0); i < (n); ++i) {
    for (long long j = (0); j < (n); ++j) {
      cin >> ch;
      if (ch == 'C') {
        col[i]++;
        row[j]++;
      }
    }
  }
  for (long long i = (0); i < (n); ++i) {
    a = col[i];
    sum += a * (a - 1) / 2;
  }
  for (long long i = (0); i < (n); ++i) {
    a = row[i];
    sum += a * (a - 1) / 2;
  }
  return sum;
}
void run() {
  cin >> n;
  cout << solve();
}
signed main() {
  std::ios::sync_with_stdio(false);
  memset(col, 0, sizeof(col));
  memset(row, 0, sizeof(row));
  run();
}
