#include <bits/stdc++.h>
using namespace std;
int n;
char ch[110][110];
int nr[210], l, ma;
int res;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    ma = 0;
    for (int j = 1; j <= n; j++) {
      cin >> ch[i][j];
      if (ch[i][j] == 'C') {
        ma++;
      }
    }
    l++;
    nr[l] = ma;
  }
  for (int i = 1; i <= n; i++) {
    ma = 0;
    for (int j = 1; j <= n; j++) {
      if (ch[j][i] == 'C') {
        ma++;
      }
    }
    l++;
    nr[l] = ma;
  }
  for (int i = 1; i <= l; i++) {
    res += ((nr[i] * (nr[i] - 1)) / 2);
  }
  cout << res;
}
