#include #define ll long long #define INF 1000000005 #define MOD 1000000007 #define EPS 1e-10 #define rep(i,n) for(int i=0;i<(int)n;++i) #define each(a,b) for(auto (a): (b)) #define all(v) (v).begin(),(v).end() #define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end()) #define fi first #define se second #define pb push_back #define show(x) cout<<#x<<" = "<<(x)<P; const int MAX_N = 3001; string c[MAX_N]; int dp[MAX_N][MAX_N]; int main() { cin.tie(0); ios::sync_with_stdio(false); int h,w; cin >> h >> w; rep(i,h){ cin >> c[i]; } rep(i,h+1){ dp[i][0] = 0; } rep(i,w+1){ dp[0][i] = 0; } rep(i,h){ rep(j,w){ if(c[i][j] == '.'){ dp[i+1][j+1] = 0; }else{ dp[i+1][j+1] = 1; } } } rep(i,h){ rep(j,w){ if(dp[i+1][j+1] == 1){ dp[i+1][j+1] = min(dp[i+1][j],min(dp[i][j+1],dp[i][j])) + 1; } } } int ans = 0; rep(i,h){ rep(j,w){ ans = max(ans,dp[i+1][j+1]); } } cout << (ans+1)/2 << endl; return 0; }