#include <bits/stdc++.h>
using namespace std;
long long int a, b, d, n, m, k, l, g;
char c[105][105];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> c[i][j];
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++) cnt += (c[i][j] == 'C');
    b += (cnt * (cnt - 1)) / 2;
  }
  for (int j = 0; j < n; j++) {
    int cnt = 0;
    for (int i = 0; i < n; i++) cnt += (c[i][j] == 'C');
    b += (cnt * (cnt - 1)) / 2;
  }
  cout << b << endl;
  return 0;
}
