import java.util.Scanner; public class Yuki402 { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int H, W; H = sc.nextInt(); W = sc.nextInt(); sc.nextLine(); int[][] dp = new int[H][W]; int ans = 0; for (int i = 0; i < H; i++) { String s = sc.nextLine(); for (int j = 0; j < W; j++) { if (s.charAt(j) == '.') { dp[i][j] = 0; } else { dp[i][j] = (int) 1e9; if (i - 1 >= 0) dp[i][j] = Math.min(dp[i][j], dp[i - 1][j]); if (j - 1 >= 0) dp[i][j] = Math.min(dp[i][j], dp[i][j - 1]); if (i - 1 >= 0 && j - 1 >= 0) dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - 1]); dp[i][j]++; ans = Math.max(ans, dp[i][j]); } } } ans = (ans + 1) / 2; System.out.println(ans); } }