/// In the name of God
#include <bits/stdc++.h>
//#define int long long
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
const int maxn = 500 + 10;
int a[maxn][maxn];
bool col[maxn];
int main()
{
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
        string s;
        cin >> s;
        for(int j=0; j<n; j++){
            a[i][j] = (s[j] == '#');
            if(a[i][j]) col[j] = 1;
        }
	}
	int bad = 0;
	bool toh = 1;
	int mn = n + 1;
	for(int i=0; i<n; i++){
        int sm = 0;
        for(int j=0; j<n; j++)
            sm += a[i][j];
        int tt = 0;
        for(int j=0; j<n; j++)
            tt += a[j][i];
        bad += (tt != n);
        if(tt) toh = 0;
        if(sm == 0) continue;
        int ned = n - sm + (col[i] == 0);
        mn = min(mn, ned);
	}
    int ans;
    if(toh) ans = -1;
    else ans = mn + bad;
    cout << ans << endl;
}
