#include <bits/stdc++.h>
using namespace std;
int summ(int x) {
  int a = 0;
  for (int i = 0; i < x; i++) a += i;
  return a;
}
int main() {
  int n;
  char ch[101][101];
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> ch[i][j];
  int c = 0;
  for (int i = 0; i < n; i++) {
    int a = 0;
    for (int j = 0; j < n; j++)
      if (ch[i][j] == 'C') a++;
    c += summ(a);
  }
  for (int i = 0; i < n; i++) {
    int a = 0;
    for (int j = 0; j < n; j++)
      if (ch[j][i] == 'C') a++;
    c += summ(a);
  }
  cout << c << endl;
}
