#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s[n];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  int y = 0;
  for (int i = 0; i < n; i++) {
    int y2 = 0;
    for (int j = 0; j < n; j++) {
      if (s[j][i] == 'C') {
        y2++;
      }
    }
    y += (y2) * (y2 - 1) / 2;
  }
  int x = 0;
  for (int i = 0; i < n; i++) {
    int x2 = 0;
    for (int j = 0; j < n; j++) {
      if (s[i][j] == 'C') {
        x2++;
      }
    }
    x += (x2) * (x2 - 1) / 2;
  }
  cout << x + y << endl;
}
