import java.util.Scanner; public class Yukicoder402 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int h = sc.nextInt(), w = sc.nextInt(); String[] s = new String[h]; int[] map = new int[h * w]; int[] dx = {-1, 0, 1, -1, 1, -1, 0, 1}; int[] dy = {-1, -1, -1, 0, 0, 1, 1, 1}; for (int i = 0; i < h; i++) { s[i] = sc.next(); for (int x = 0; x < w; x++) { if (s[i].charAt(x) == '.') { map[i * w + x] = 0; } else { map[i * w + x] = 1; } } } int min, max = -1; for (int k = 1; k < 1500; k++) { for (int y = k; y < h - k; y++) { for (int x = k; x < w - k; x++) { if (map[y * w + x] != 0) { min = map[(y + dy[0]) * w + (x + dx[0])]; for (int p = 1; p < 8; p++) { min = Math.min(min, map[(y + dy[p]) * w + (x + dx[p])]); } map[y * w + x] = min + 1; max = Math.max(max, map[y * w + x]); } } } } System.out.println(max); } }