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

char mas[510][510];

int main(){
    int n;
    cin >> n;

    for(int i = 0;i < n;i++){
        cin >> mas[i];
    }

    int last = 0;
    int white = 0;
    int re[510] = {};
    for(int j = 0;j < n;j++){
        for(int i = 0;i < n;i++){
            re[j] += mas[i][j] == '.' ? 1 : 0;
            white += mas[i][j] == '.' ? 1 : 0;
        }

        if(re[j] != 0) last++;
    }

    if(white == n*n){
        cout << -1 << endl;
        return 0;
    }

    int ans = INT_MAX;

    for(int i = 0;i < n;i++){
        int cnt = 0;
        for(int j = 0;j < n;j++){
            if(mas[i][j] == '.'){
                cnt++;
            }
        }

        if(re[i] == n){
            cnt++;
        }

        ans = min(ans, cnt);
    }

    cout << ans+last << endl;

    return 0;
}
