#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> arr;
  for (int i = 0; i < n; i++) {
    string x;
    cin >> x;
    arr.push_back(x);
  }
  int chocolate = 0;
  for (int i = 0; i < n; i++) {
    int temp = 0;
    temp = count(arr[i].begin(), arr[i].end(), 'C');
    chocolate += (temp * (temp - 1)) / 2;
  }
  for (int i = 0; i < n; i++) {
    int temp = 0;
    for (int j = 0; j < n; j++) {
      if (arr[j][i] == 'C') {
        temp += 1;
      }
    }
    chocolate += (temp * (temp - 1)) / 2;
  }
  cout << chocolate << endl;
  return 0;
}
