module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){r(1)(r(2).readFileSync("/dev/stdin","UTF-8"))},function(t,e){t.exports=function(t){for(var e=t.split("\n"),r=e[0].split(" "),n=Number(r[0]),o=Number(r[1]),i=[],u=0,s=[],f=0;f<n;f++){for(var d=e[f+1].split(""),l=0;l<o;l++)"#"==d[l]?s.push({x:l,y:f,dist:0}):u+=1;i.push(d)}for(;s.length>0;){var y=s.shift();if("."==i[y.y][y.x]||0==y.dist){if("."==i[y.y][y.x]&&(i[y.y][y.x]="#",u-=1),u<=0)return void console.log(y.dist);y.x+1<o&&"#"!=i[y.y][y.x+1]&&s.push({x:y.x+1,y:y.y,dist:y.dist+1}),y.x-1>=0&&"#"!=i[y.y][y.x-1]&&s.push({x:y.x-1,y:y.y,dist:y.dist+1}),y.y+1<n&&"#"!=i[y.y+1][y.x]&&s.push({x:y.x,y:y.y+1,dist:y.dist+1}),y.y-1>=0&&"#"!=i[y.y-1][y.x]&&s.push({x:y.x,y:y.y-1,dist:y.dist+1})}}}},function(t,e){t.exports=require("fs")}]);