#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a = -1, ans = 0, q;
  cin >> n;
  char arr[n][n];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> arr[i][j];
  for (int i = 0; i < n; i++) {
    a = -1, q = 0;
    for (int j = 0; j < n; j++) {
      if (arr[i][j] == 'C') {
        a++;
        if (a > 0) {
          q++;
          ans += q;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    a = -1, q = 0;
    for (int j = 0; j < n; j++) {
      if (arr[j][i] == 'C') {
        a++;
        if (a > 0) {
          q++;
          ans += q;
        }
      }
    }
  }
  cout << ans;
  return 0;
}
