#include <bits/stdc++.h>
using namespace std;
int n;
char a[105][105];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  int Ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[i][j] == 'C') {
        for (int k = i + 1; k < n; k++) {
          Ans += (a[i][j] == a[k][j]);
        }
        for (int k = j + 1; k < n; k++) {
          Ans += (a[i][j] == a[i][k]);
        }
      }
    }
  }
  cout << Ans;
  return 0;
}
