import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;
import std.math;

auto solve(immutable int n)
{
    auto a = iota(n).map!(_=>readln().chomp()).array();
    auto dp = new int[][](n+1,n+1);
    foreach(i;0..n)
        foreach(j;0..n)
            dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j]-dp[i][j]+(a[i][j]!='.'?1:0);
    if(dp[n][n]==n*n) return 0;
    immutable int m = cast(int)(floor(sqrt(cast(real)(n*n-dp[n][n]))));
    foreach_reverse(k;2..m+1)
        foreach(i;0..n-k+1)
            foreach(j;0..n-k+1)
                if(0==dp[i+k][j+k]-dp[i][j+k]-dp[i+k][j]+dp[i][j])
                    return k;
    return 1;
}

void main()
{
    for(int n; 0!=(n=readln().chomp().to!int()); )
        writeln(solve(n));
}