import std.stdio;

void main()
{
	int n;
	
	scanf("%d", &n);
	
	char[][] m = new char[][n];
	
	for (int i = 0; i < n; i++) {
		m[i] = new char[n + 1];
		scanf("%s", m[i].ptr);
	}
	
	int res = 0;
	for (int i = 0; i < n; i++) {
		int r = 0;
		int c = 0;
		for (int j = 0; j < n; j++) {
			if (m[j][i] == 'C')
				c++;
			if (m[i][j] == 'C')
				r++;
		}
		
		res += (r - 1) * r / 2;
		res += (c - 1) * c / 2;
	}
	
	printf("%d\n", res);
}
