#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); ll n; cin >> n; vector s(n); for(auto &&e: s) cin >> e; ll z, G = n*n*(n+1)/2, y = 0, t = 0, v = 0; for(ll i = 0; i < n; ++i){ for(ll j = 0; j < n*2; ++j){ if(s[i][j] == '.') { y += (j+1); ++v; } } if(i != n-1)t += abs(v - ((i+1)*n)); } z = y - G; z += t; cout << z << '\n'; return 0; }