#include using namespace std; const short inf = 3e4; int h, w; int a[3002][3002]; string s[3002]; int main() { cin >> h >> w; s[0] = string(w + 2, '.'); s[h + 1] = string(w + 2, '.'); for (int i = 0; i < h; ++i) { string t; cin >> t; s[i + 1] = '.' + t + '.'; } int mx = 0; for (int i = 1; i <= h; ++i) { for (int j = 1; j <= w; ++j) { if (s[i][j] == '#') { a[i][j] = min({ a[i - 1][j - 1], a[i - 1][j], a[i][j - 1] }) + 1; mx = max(mx, a[i][j]); } } } cout << (mx + 1) / 2 << endl; }