#include <iostream>
using namespace std;
const int MN = 105;
char board[MN][MN];
int main()
{
int n;
cin >> n;
for(int i = 0; i < n; ++i) cin >> board[i];
long long ans = 0;
for(int i = 0; i < n; ++i){
int cnt = 0;
for(int j = 0; j < n; ++j){
cnt += board[i][j] == 'C';
}
if (cnt > 1){
ans += cnt * (cnt - 1) / 2;
}
cnt = 0;
for(int j = 0; j < n; ++j){
cnt += board[j][i] == 'C';
}
if (cnt > 1){
ans += cnt * (cnt - 1) / 2;
}
}
cout << ans << '\n';
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1OID0gMTA1OwpjaGFyIGJvYXJkW01OXVtNTl07CmludCBtYWluKCkKewoJaW50IG47CgljaW4gPj4gbjsKCWZvcihpbnQgaSA9IDA7IGkgPCBuOyArK2kpIGNpbiA+PiBib2FyZFtpXTsKCWxvbmcgbG9uZyBhbnMgPSAwOwoJZm9yKGludCBpID0gMDsgaSA8IG47ICsraSl7CgkJaW50IGNudCA9IDA7CgkJZm9yKGludCBqID0gMDsgaiA8IG47ICsrail7CgkJCWNudCArPSBib2FyZFtpXVtqXSA9PSAnQyc7CgkJfQoJCWlmIChjbnQgPiAxKXsKCQkJYW5zICs9IGNudCAqIChjbnQgLSAxKSAvIDI7CgkJfQoJCWNudCA9IDA7CgkJZm9yKGludCBqID0gMDsgaiA8IG47ICsrail7CgkJCWNudCArPSBib2FyZFtqXVtpXSA9PSAnQyc7CgkJfQoJCWlmIChjbnQgPiAxKXsKCQkJYW5zICs9IGNudCAqIChjbnQgLSAxKSAvIDI7CgkJfQoJfQoJY291dCA8PCBhbnMgPDwgJ1xuJzsKfQo=