#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N;
string s[500];
int main(){
	cin>>N;
	rep(i,N) cin>>s[i];
	bool all0=1;
	rep(i,N) rep(j,N){
		if(s[i][j]=='#') all0=0;
	}
	if(all0){
		puts("-1");
		return 0;
	}
	int already_column=0;
	rep(i,N){
		bool ok=1;
		rep(j,N) if(s[j][i]=='.') ok=0;
		if(ok) already_column++;
	}
	int inf=1e9;
	int ans=inf;
	rep(i,N){
		bool can=0;
		rep(j,N) if(s[j][i]=='#') can=1;
		int hole=0;
		rep(j,N) if(s[i][j]=='.') hole++;
		chmin(ans,(can?0:1)+hole+N-already_column);
	}
	cout<<ans<<endl;
}
