#include <bits/stdc++.h>
using namespace std;
//#define DEBUG_MODE
#define endl '\n'
#ifdef DEBUG_MODE
#define DEBUG(X) debug_func(X, #X)
#define DEBUG_ENDL endl << flush
#define DEBUG_SEPARATOR_LINE cout<<"=================\n"
#else
#define DEBUG(X) 0
#define DEBUG_ENDL 0
#define DEBUG_SEPARATOR_LINE 0
#endif
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "") << flush;
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; }
template <typename T>
void debug_func(const T &t, const string &s = "") {
    debug_func_preffix(s);
    cout << t << DEBUG_ENDL_S(s);
}
template <typename T, typename U>
void debug_func(const P<T, U> &p, const string &s = "") {
    debug_func_preffix(s);
    cout << "(";
    debug_func(p.first);
    cout << ", ";
    debug_func(p.second);
    cout << ")" << DEBUG_ENDL_S(s);
}
template <typename T>
void debug_func(const V<T> &v, const string &s = "") {
    for(ll i = 0; i < v.size(); i++) {
        string t = s + "[" + to_string(i) + "]";
        debug_func(v[i], t);
    }
}

void init_io() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(30);
}

ll N;
V<string> A;

ll solve() {
    {
        bool find = false;
        for(const auto &s : A) for(char c : s) if(c == '#') find = true;
        if(!find) return -1;
    }
    V<bool> exist_row_black(N, false);
    V<ll> cnt_col_white(N);
    V<ll> cnt_row_white(N);
    for(ll row = 0; row < N; row++) for(ll col = 0; col < N; col++)  if(A[row][col] == '.') cnt_row_white[row]++;
    for(ll col = 0; col < N; col++) {
        for(ll i = 0; i < N; i++) {
            char c = A[i][col];
            if(c == '.') cnt_col_white[col]++;
            else exist_row_black[i] = true;
        }
    }

    ll ans = 5e15;
    for(ll col = 0; col < N; col++) {
        ll tmp = !exist_row_black[col];
        tmp += cnt_col_white[col];
        for(ll i = 0; i < N; i++) tmp += (A[i][col] == '.' ? 1 : cnt_row_white[i] > 0);
        chmin(ans, tmp);
    }
    return ans;
}

#ifdef DEBUG_MODE

int main() {
    while(1) {
        cin >> N;
        if(N == 0) break;
        A = V<string>(N);
        for(auto &e : A) cin >> e;
        ll ans = solve();
        for(auto &s : A) cout << s << endl;
        cout << ans << endl;
        cout << endl;
        DEBUG_SEPARATOR_LINE;
        cout << endl;

    }
    return 0;
}

#else

int main() {
    cin >> N;
    A = V<string>(N);
    for(auto &e : A) cin >> e;
    {
        auto B = A;
        for(ll i = 0; i < N; i++) for(ll j = 0; j < N; j++) A[i][j] = B[j][i];
    }
    ll ans = solve();
    cout << ans << endl;
    return 0;
}

#endif


Measured memory_bytes: 768