#include <bits/stdc++.h>
using namespace std;

int main() {
    int n; cin >> n;
    vector<string> grid(n);
    for (int i = 0; i < n; ++i) cin >> grid[i];
    bool fl = true;
    for (int i = 0; i < n; ++i) fl &= count(grid[i].begin(), grid[i].end(), '#') == 0;
    if (fl) {
        cout << -1 << endl;
        return 0;
    }
    int ans = n * n * n;
    vector<int> ok(n), cl(n);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (grid[i][j] == '#') ok[j] = 1;
        }
    }
    int cf = 0;
    for (int i = 0; i < n; ++i) {
        int wh = -1, cnt = 0;
        for (int j = 0; j < n; ++j) {
            if (grid[j][i] == '.') {
                cnt++;
                wh = j;
            }
        }
        if (cnt == 0) ++cf;
        else if (cnt == 1) ++cl[wh];
    }
    for (int i = 0; i < n; ++i) {
        int cv = count(grid[i].begin(), grid[i].end(), '#');
        int res = 0;
        if (cv < n) {
            if (!ok[i]) res++;
            res += n - cv;
        }
        res += n - cf;
        ans = min(ans, res);
    }
    cout << ans << "\n";
    return 0;
}
