#include <bits/stdc++.h>
using namespace std;
char cake[100][100];
int amount[100][100];
int happiness;
int chocrow;
int choccol;
int dimension;
int main() {
  cin >> dimension;
  for (int i = 0; i < dimension; i++) {
    for (int j = 0; j < dimension; j++) {
      cin >> cake[i][j];
    }
  }
  for (int i = 0; i < dimension; i++) {
    chocrow = 0;
    for (int j = 0; j < dimension; j++) {
      if (cake[i][j] == 'C') {
        chocrow++;
      }
    }
    happiness += (chocrow * (chocrow - 1)) / 2;
  }
  for (int j = 0; j < dimension; j++) {
    chocrow = 0;
    for (int i = 0; i < dimension; i++) {
      if (cake[i][j] == 'C') {
        chocrow++;
      }
    }
    happiness += (chocrow * (chocrow - 1)) / 2;
  }
  cout << happiness << endl;
}
