#include <bits/stdc++.h>
using namespace std;
char arr[105][105];
int n, res;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int x = 0; x < n; x++) {
    for (int y1 = 0; y1 < n; y1++) {
      for (int y2 = y1 + 1; y2 < n; y2++) {
        if (arr[x][y1] == 'C' && arr[x][y2] == 'C') {
          res++;
        }
        if (arr[y1][x] == 'C' && arr[y2][x] == 'C') {
          res++;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}
