#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n;
	cin >> n;
	string a[n];
	zep(i, 0, n){
		cin >> a[i];
	}
	
	ll cnti[n], cntj[n];
	memset(cnti, 0, sizeof(cnti));
	memset(cntj, 0, sizeof(cntj));
	
	ll z = 0;
	zep(i, 0, n){
		zep(j, 0, n){
			if(a[i][j] == '#'){
				cnti[i]++;
				cntj[j]++;
			}
			else{
				z++;
			}
		}
	}
	if(z == n*n){
		print(-1)
		return 0;
	}
	
	ll cost = n;
	zep(i, 0, n){
		if(cntj[i] > 0){
			cost = min(n-cnti[i], cost);
		}
		else{
			cost = min(n-cnti[i]+1, cost);
		}
	}
	
	ll cnt = 0;
	zep(j, 0, n){
		if(cntj[j] == n){
			cnt++;
		}
	}
	print(n-cnt+cost)
	return 0;
}