import java.io.PrintWriter; import java.util.LinkedList; import java.util.Scanner; public class Main { static Scanner scan = new Scanner(System.in); static PrintWriter out = new PrintWriter(System.out); static int H, W; static char[][] map; static int [][] ansMap; static int ans = 0; public static void main(String[] args) { H = scan.nextInt(); W = scan.nextInt(); LinkedList q = new LinkedList<>(); map = new char[H+2][W+2]; ansMap = new int[H+2][W+2]; for(int i=0; i= 0 && nextX < map[0].length && nextY >= 0 && nextY < map.length) { if(map[nextY][nextX] == '#' && ansMap[nextY][nextX] == 0) { ansMap[nextY][nextX] = ansMap[now.y][now.x] + 1; q.add(new Point(nextX, nextY)); ans = Math.max(ans, ansMap[nextY][nextX]); } } } } System.out.println(ans); } static class Point { int x, y; Point(int x, int y) { this.x = x; this.y = y; } } }