#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)






int main() {
    ll n;
    cin >> n;
    vector<string> a(n);
    bool black = false;
    REP(i, n){
        cin >> a[i];
        REP(j, n){
            if(a[i][j] == '#') black = true;
        }
    }
    if(!black){
        cout << -1 << endl;
        return 0;
    }
    
    auto t = a;
    vector<ll> black_i(n, -1);
    REP(i, n){
        REP(j, n){
            if(black_i[j] == -1 && t[i][j] == '#'){
                black_i[j] = i;
            }
        }
    }
    ll res1 = INF, idx1 = 0;
    REP(i, n){
        if(black_i[i] == -1) continue;
        ll cnt = 0;
        REP(j, n){
            if(t[i][j] == '.') cnt++;
        }
        if(res1 > cnt){
            res1 = cnt;
            idx1 = i;
        }
    }
    // cerr << "res1: " << res1 << " idx1: " << idx1 << endl;
    REP(j, n){
        if(t[idx1][j] == '.' && idx1 != j){
            string tmp = t[black_i[idx1]];
            REP(i, n){
                t[i][j] = tmp[i];
            }
        }
    }
    if(t[idx1][idx1] == '.'){
        string tmp = t[black_i[idx1]];
        REP(i, n){
            t[i][idx1] = tmp[i];
        }
    }
    
    /*
    REP(i, n){
        cerr << t[i] << endl;
    }
    */
    
    ll res2 = 0;
    REP(j, n){
        bool white = false;
        REP(i, n){
            if(t[i][j] == '.') white = true;
        }
        if(white) res2++;
    }
    
    ll ans = res1 + res2;
    
    t = a;
    ll res3 = INF, idx2 = 0;
    REP(i, n){
        if(black_i[i] != -1) continue;
        ll cnt = 1;
        REP(j, n){
            if(t[i][j] == '.') cnt++;
        }
        if(res3 > cnt){
            res3 = cnt;
            idx2 = i;
        }
    }
    // cerr << "res3: " << res3 << " idx2: " << idx2 << endl;
    if(res3 != INF){
        REP(i, n){
            bool b = false;
            REP(j, n){
                if(t[i][j] == '#'){
                    black_i[idx2] = j;
                    b = true;
                    break;
                }
            }
            if(b){
                string tmp = t[i];
                REP(j, n){
                    t[i][idx2] = tmp[j];
                }
                break;
            }
        }
        REP(j, n){
            if(t[idx2][j] == '.' && idx2 != j){
                string tmp = t[black_i[idx2]];
                REP(i, n){
                    t[i][j] = tmp[i];
                }
            }
        }
        if(t[idx2][idx2] == '.'){
            string tmp = t[black_i[idx2]];
            REP(i, n){
                t[i][idx2] = tmp[i];
            }
        }
        
        ll res4 = 0;
        REP(j, n){
            bool white = false;
            REP(i, n){
                if(t[i][j] == '.') white = true;
            }
            if(white) res4++;
        }
        
        ans = min(ans, res3 + res4);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 768