#include <bits/stdc++.h>

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.1415926535897932384626

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

int n, exists_black, perfect_col, least_row_cost;
char s[505][505];

void solve(){
	FI(i, 1, n){
		int cnt = 0;
		FI(j, 1, n) if(s[j][i] == '#') cnt++;
		if(cnt == n) perfect_col++;
	}
	
	least_row_cost = n;
	
	FI(i, 1, n){
		int c = 0, ok = false;
		FI(j, 1, n) if(s[j][i] == '#'){
			ok = true;
			break;
		}
		FI(j, 1, n) if(s[i][j] == '.') c++;
		if(!ok) c++;
		least_row_cost = min(least_row_cost, c);
	}
	printf("%d\n", least_row_cost + n - perfect_col);
	return;
}

int main(){
	scanf("%d", &n);
	FI(i, 1, n){
		scanf("\n%s", s[i] + 1);
		FI(j, 1, n) if(s[i][j] == '#') exists_black = true;
	}
	
	if(!exists_black){
		printf("-1\n");
		return 0;
	}
	
	solve();
	
	return 0;
}
