#include <bits/stdc++.h>
using namespace std;
struct st {
  int x;
  int y;
};
bool fun(const st &a, const st &b) { return a.x < b.x; }
int main() {
  long long t, ans, i, j, x, n;
  char str[105][105];
  t = 1;
  while (t--) {
    cin >> n;
    for (i = 0; i < n; i++) {
      scanf("%s", str[i]);
    }
    ans = 0;
    for (i = 0; i < n; i++) {
      x = 0;
      for (j = 0; j < n; j++)
        if (str[i][j] == 'C') x++;
      ans = (long long)ans + (long long)x * (x - 1) / 2.0;
    }
    for (j = 0; j < n; j++) {
      x = 0;
      for (i = 0; i < n; i++)
        if (str[i][j] == 'C') x++;
      ans = (long long)ans + (long long)x * (x - 1) / 2.0;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
