import java.util.Scanner; class Yuki2_2{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int H = sc.nextInt(); int W = sc.nextInt(); int dp[][] = new int[H + 2][W + 2]; int res = 0; for(int i = 1; i <= H; i++){ String input = sc.next(); for(int j = 1; j <= W; j++){ if(input.charAt(j - 1) == '#'){ dp[i][j] = Math.min(dp[i - 1][j - 1], Math.min(dp[i - 1][j], dp[i][j - 1])) + 1; res = Math.max(res, dp[i][j]); } } } System.out.println((res + 1) / 2); } }