#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#define rep(i, n) for(int i=0;i<n;i++)
#define FOR(i, j, n) for(int i=j;i<n;i++)
#define LEVEL 0
#define DEBUG if(LEVEL)

using namespace std;

int N = 0;
char** data;
int result = 0;
int search(int x, int y);

void print_data(int n) {
    rep(i, n) {
        rep(j, n) {
            DEBUG cout << data[i][j];
        }
        DEBUG cout << endl;
    }
}

int next_search(int x, int y) {
    int next_x, next_y = 0;
    if (x == N - 1) {
        if (y == N - 1) return 0;

        return search(0, y + 1);
    }

    return search(x + 1, y);
}

int search(int x, int y) {
    if (y + result  > N - 1) return 0;

    FOR(i, x, N) {

        if (x + i == N || y + i == N)
            return next_search(x, y);

        FOR(k, x, x + i) {
            FOR(l, y,  y + i) {
                if(data[k][l] == '.') {
                    continue;
                }
                return next_search(x, y);
            }
        }
        result = result < i ? i : result;
    }

    return 0;
}


int main() {
    while(1) {
        cin >> N;
        if (N == 0) return 0;
        data = (char**)malloc(sizeof(char*) * N);
        rep(i, N) data[i] = (char*)malloc(sizeof(char) * N);
        rep(i, N) rep(j, N) cin >> data[i][j];
        print_data(N);
        search(0, 0);
        cout << result << endl;
        result = 0;
        free(data);
    }

    return 0;
}