#include "bits/stdc++.h" using namespace std; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL; typedef vector vi; typedef pair pii; typedef vector > vpii; typedef long long ll; template static void amin(T &x, U y) { if(y < x) x = y; } template static void amax(T &x, U y) { if(x < y) x = y; } int main() { int H; int W; while(~scanf("%d%d%*c", &H, &W)) { vector> S(H); rep(i, H) { S[i] = make_unique(W + 2); fgets(S[i].get(), W + 2, stdin); } vector> dp(H + 1, vector(W + 1)); int m = 0; rep(i, H) rep(j, W) if(S[i][j] == '#') { int x = min({ dp[i][j + 1], dp[i + 1][j], dp[i][j] }) + 1; amax(m, x); dp[i + 1][j + 1] = x; } int ans = (m + 1) / 2; printf("%d\n", ans); } return 0; }