#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:100000000")
int ri() {
  int x;
  scanf("%d", &x);
  return x;
}
string matrix[111];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    cin >> matrix[i];
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      cnt += (matrix[i][j] == 'C');
    }
    res += cnt * (cnt - 1) / 2;
  }
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      cnt += (matrix[j][i] == 'C');
    }
    res += cnt * (cnt - 1) / 2;
  }
  cout << res << endl;
  return 0;
}
