#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
const ll MOD = 1000000007;

string S[500];
int row[500], colomn[500];

int main() {
	int N;
	cin >> N;
	for (int i = 0;i < N;i++) {
		cin >> S[i];
	}
	int ness = 0;
	for (int i = 0;i < N;i++) {
		row[i] = 0;
		for (int j = 0;j < N;j++) {
			if (S[i][j] == '#')row[i]++, ness++;
		}
	}
	if (ness == 0) {
		cout << -1 << endl;
		return 0;
	}
	ness = 0;
	for (int i = 0;i < N;i++) {
		colomn[i] = 0;
		for (int j = 0;j < N;j++) {
			if (S[j][i] == '#')colomn[i]++;
		}
		if (colomn[i] == N)ness++;
	}
	

	int ans = INT32_MAX;
	for (int i = 0;i < N;i++) {
		if (colomn[i] == 0) {
			ans = min(ans, 1 + (N - row[i]) + (N - ness));
		}
		else {
			ans = min(ans, (N - row[i]) + (N - ness));
		}
	}
	cout << ans << endl;
}