#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long inf = 1ll << 62;
typedef pair<int, int> P;
string a[501];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	int cnt = 0;
	rep(i, n)rep(j, n)if (a[i][j] == '#')cnt++;
	if (!cnt) {
		cout << -1 << endl;
		return 0;
	}
	cnt = inf;
	int finc = 0;

	rep(j, n) {
		int c = 0;
		rep(i, n) {
			if (a[i][j] == '#')c++;
		}
		if (c == n)finc++;
	}

	rep(i, n) {
		int f = 0;
		rep(j, n) {
			if (a[i][j] == '.')f++;
		}
		int is = 0;
		rep(j, n) {
			if (a[j][i] == '#')is++;
		}
		if (is)cnt = min(cnt, f);
		else cnt = min(cnt, f + 1);
	}
	cout << cnt + n - finc << endl;

}