#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F0(i,n) for (int i = 0; i < n; i++)
#define F1(i,n) for (int i = 1; i <= n; i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define SZ(x) ((int)x.size())
const double eps = 1e-10;
const int inf = 1000000009;
int i, j, k, m, n, l;
int ans = -1;
string s[505];
int have[505];

int main() {
	//freopen("x.in", "r", stdin);
	cin >> n;
	F0(i, n) {
		cin >> s[i];
		F0(j, n) if (s[i][j] == '#') {
			have[j] = 1;
			ans = 0;
		}
	}
	if (ans < 0) {
		cout << -1 << endl;
	}
	else {
		int best_row = -1;
		F0(i, n) {
			int cnt = 0;
			F0(j, n) cnt += (s[i][j] == '#');
			best_row = max(best_row, cnt + have[i]);
		}
		ans = n + 1 - best_row;
		F0(j, n) {
			int is_empty = 0;
			F0(i, n) if (s[i][j] == '.') is_empty = 1;
			ans += is_empty;
		}
		cout << ans << endl;
	}
	return 0;
}
