#include <bits/stdc++.h>
using namespace std;
char a[100][100];
int b[101];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> a[i][j];
    }
  }
  for (int i = 2; i <= n; ++i) {
    b[i] = i - 1 + b[i - 1];
  }
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    int c = 0;
    for (int j = 0; j < n; ++j) {
      if (a[i][j] == 'C') c++;
    }
    sum += b[c];
  }
  for (int j = 0; j < n; ++j) {
    int c = 0;
    for (int i = 0; i < n; ++i) {
      if (a[i][j] == 'C') {
        c++;
      }
    }
    sum += b[c];
  }
  cout << sum;
  return 0;
}
