//C++11

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

const int MAXN = 1000;
int n;
bool mat[MAXN][MAXN];
bool tmp[MAXN][MAXN];

int solve(void)
{
    bool empty;
    empty = false;
    REP(i,n) REP(j,n) empty = empty || mat[i][j]; 
    if(!empty) return 0;
    for(int l=1;l<=n-1;l++){
        empty = false;
        REP(i,n-l){ REP(j,n-l){
            tmp[i][j] = mat[i][j] && mat[i+1][j] && mat[i][j+1] && mat[i+1][j+1];
            empty = empty || tmp[i][j];
        }}
        REP(i,n-l) REP(j,n-l) mat[i][j] = tmp[i][j];
        if(!empty) return l;
    }
    return n;
}

int main(void)
{
    while(true){
        //read
        cin >> n;
        if(!n) break;
        REP(j,n){ 
            string s;
            cin >> s;
            REP(i,n) mat[i][j] = (s[i]=='.') ? true : false;
        }
        //solve and print
        int res = solve();
        cout << res << endl;
    }
    return 0;
}