#include <bits/stdc++.h>
using namespace std;
int n;
vector<string> polje;
int main() {
  cin >> n;
  polje.resize(n);
  int sol = 0;
  for (int i = 0; i < n; ++i) {
    cin >> polje[i];
    for (int j = 0; j < n; ++j) {
      if (polje[i][j] == 'C') {
        for (int k = j + 1; k < n; ++k) {
          if (polje[i][k] == 'C') sol++;
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (polje[j][i] == 'C') {
        for (int k = j + 1; k < n; ++k) {
          if (polje[k][i] == 'C') sol++;
        }
      }
    }
  }
  cout << sol << endl;
  return 0;
}
