/*
Aizu Vol-0 0092: Square Searching
2017.8.12 bal4u@uu
????????°n???????????£?¶????????????????1??????????????????k?
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *gets();

#define SIZE 1000
char buf[SIZE + 5], *p, *pe;

#define W 32   //  must > 1000/32
unsigned map[SIZE + 10][W], *q; int len;

int lt[256] = {
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8 };
int rt[256] = {
    0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 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, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 0,
    0, 0, 1, 0, 1, 1, 2, 0, 1, 1, 1, 1, 2, 2, 3, 0, 1, 1, 1, 1, 1, 1, 2, 1, 2, 2, 2, 2, 3, 3, 4, 0,
    1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 0,
    0, 0, 1, 0, 1, 1, 2, 0, 1, 1, 1, 1, 2, 2, 3, 0, 1, 1, 1, 1, 1, 1, 2, 1, 2, 2, 2, 2, 3, 3, 4, 0,
    0, 0, 1, 0, 1, 1, 2, 0, 1, 1, 1, 1, 2, 2, 3, 0, 0, 0, 1, 0, 1, 1, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0 };

int maxBits(unsigned *a, int len)
{
	int i, k, n, p, l, m, r;
	unsigned *e = a + len;
	k = p = 0;
	while (a < e) {
        if (!*a) { if (p > k) k = p; p = 0; }
        else if (*a == 0xffffffffU) p += 32;
        else {
            for (i = 24; i >= 0; i -= 8) {
                n = ((*a) >> i) & 0xff;
                l = lt[n], m = mt[n], r = rt[n];
                if (l == 8) p += 8;
                else {
                    if (m > k) k = m;
                    p += l; if (p > k) k = p; p = r;
                }
            }
		}
		a++;
	}
	if (p > k) k = p;
	return k;
}

int main()
{
	int n, i, j, k, max;
	unsigned m, *d;

	while (1) {
		gets(buf); if (!(n = atoi(buf))) break;
		pe = buf + n, max = 0;
		for (i = 0; i < n; i++) {
			gets(p = buf), q = map[i], k = 0, m = 0;
			while (p < pe) {
				m <<= 1;
				if (*p++ == '.') m |= 1;
				if (++k == 32) { if (m) max = 1; *q++ = m, k = 0, m = 0; }
			}
			if (k) {m <<= (32-k); *q++ = m; if (m) max = 1; }
			len = q - map[i];
		}
		if (!max) { puts("0"); continue; }
		for (i = 0; i < n; i++) {
			for (j = i + 1; j < n; j++) {
				for (d = map[i], q = map[j], k = len; k--; ) *d++ &= *q++;
				k = maxBits(map[i], len);
                if (k < max) break;
                if (k > j - i + 1) k = j - i + 1;
                if (k > max) max = k;
			}
		}
		printf("%d\n", max);
	}
	return 0;
}

Measured memory_bytes: 652