#include<iostream>
using namespace std;
int board[1001][1001];
int main(void) {
	int n;
	while (1) {
		char l;
		cin >> n;
		if (n == 0)break;
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				cin >> l;
				if(l=='.')	board[i][j] = 1;
				else board[i][j] = 0;
			}
		}
		int  count=1;
		while (count) {
			int judge = 1;
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= n; j++) {
					if (board[i - 1][j - 1] >= count - 1 && board[i - 1][j] >= count - 1 && board[i][j - 1] >= count - 1&&board[i][j]!=0) {
						board[i][j] = count;
						judge = 0;
					}
				}
			}
			if (judge) break;
			count++;
		}
		cout << count-1 << endl;
	}
}