#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ans = 0;
  char c[110][110];
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> c[i][j];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (c[i][j] == 'C') {
        for (int i2 = i + 1; i2 < n; i2++)
          if (c[i2][j] == 'C') ans++;
        for (int j2 = j + 1; j2 < n; j2++)
          if (c[i][j2] == 'C') ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
