import java.io.*; import java.util.*; public class Main_yukicoder402 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); int[] dx = {1, 0, -1, 0}; int[] dy = {0, 1, 0, -1}; int h = sc.nextInt(); int w = sc.nextInt(); char[][] s = new char[h][]; int[][] ss = new int[h][w]; for (int i = 0; i < h; i++) { s[i] = sc.next().toCharArray(); for (int j = 0; j < w; j++) { if (s[i][j] == '#') { ss[i][j] = 1; } } } int[][] sum = new int[h + 1][w + 1]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { sum[i + 1][j + 1] = sum[i + 1][j] + ss[i][j]; } } for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { sum[i + 1][j + 1] += sum[i][j + 1]; } } int max = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (s[i][j] != '#') { continue; } for (int k = max; k <= Math.min(h, w); k++) { if (i + k + 1 > h || j + k + 1 > w) { break; } int tmp = sum[i + k + 1][j + k + 1] - sum[i + k + 1][j] - sum[i][j + k + 1] + sum[i][j]; if (tmp == (k + 1) * (k + 1)) { max = Math.max(max, k); } else { break; } } } } pr.println((max + 2) / 2); pr.close(); sc.close(); } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { // it = Arrays.asList(br.readLine().split(" ")).iterator(); it = Arrays.asList(br.readLine().split("\\p{javaWhitespace}+")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }