import java.util.Scanner; public class Main { public static void main(String[] args) { solver(); } static void solver() { Scanner sc = new Scanner(System.in); int H = sc.nextInt(); int W = sc.nextInt(); char[][] table = new char[H][W]; dis = new int[H][W]; for (int i = 0; i < H; i++) { table[i] = sc.next().toCharArray(); } int[][] dp = new int[H + 2][W + 2]; int ans = 0; for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { if (table[i-1][j-1] == '.') continue; dp[i][j] = Math.min(dp[i - 1][j - 1] + 1, dp[i - 1][j] + 1); dp[i][j] = Math.min(dp[i][j], dp[i][j - 1] + 1); ans = Math.max(ans, dp[i][j]); } } System.out.println((ans + 1) / 2); } static int[][] dis; }