#include <bits/stdc++.h>
using namespace std;
deque<int> v;
int t, n, m, i, j, ans, k, a, b, c, d, e, f, sz, q, x;
string s, s2, s3, s4, s5, s6;
int ar[(int)(1e5 + 10)], ar2[(int)(1e5 + 10)];
void brainfuck();
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  brainfuck();
  return 0;
}
void brainfuck() {
  char grid[110][110];
  cin >> n;
  for (i = 0; i != n; i++) cin >> grid[i];
  for (i = 0; i != n; i++) {
    b = c = 0;
    for (j = 0; j != n; j++) {
      if (grid[i][j] == 'C') b++;
      if (grid[j][i] == 'C') c++;
    }
    a += (b * (b - 1)) / 2;
    a += (c * (c - 1)) / 2;
  }
  cout << a;
}
