#include <bits/stdc++.h>
const int dx[] = {0, -1, 0, 1, -1, 1, 1, -1, -2, -2, 2, 2, -1, -1, 1, 1};
const int dy[] = {-1, 0, 1, 0, 1, 1, -1, -1, -1, 1, -1, 1, -2, 2, -2, 2};
using namespace std;
int main(int argc, char const *argv[]) {
  int x;
  scanf("%d", &x);
  vector<string> in(x);
  for (int i = 0; i < x; i++) cin >> in[i];
  int sum = 0;
  for (int i = 0; i < x; i++) {
    int cnt = 0;
    for (int j = 0; j < x; j++) {
      if (in[i][j] == 'C') cnt++;
    }
    sum += (cnt * (cnt - 1)) / 2;
  }
  for (int i = 0; i < x; i++) {
    int cnt = 0;
    for (int j = 0; j < x; j++) {
      if (in[j][i] == 'C') cnt++;
    }
    sum += (cnt * (cnt - 1)) / 2;
  }
  cout << sum << endl;
}
