#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int T;
  cin >> T;
  vector<string> cake;
  for (int i = 0; i < T; ++i) {
    string x;
    cin >> x;
    cake.push_back(x);
  }
  int res = 0;
  for (int i = 0; i < T; ++i) {
    int row = 0;
    int col = 0;
    for (int j = 0; j < T; ++j) {
      if (cake[i][j] == 'C') {
        ++row;
      }
      if (cake[j][i] == 'C') {
        ++col;
      }
    }
    if (row >= 2) {
      res += (row * (row - 1)) / 2;
    }
    if (col >= 2) {
      res += (col * (col - 1)) / 2;
    }
  }
  cout << res;
  return 0;
}
