#import <Foundation/Foundation.h>
int H,W;
void addToSet(NSString *obj, NSMutableSet *set){
    if (obj) {
        [set addObject:obj];
    }
}
void addToSetIfNotVisited(NSString *obj, NSMutableSet *set, NSMutableSet *visited){
    if (obj) {
        if (![visited containsObject:obj]) {
            [set addObject:obj];
        }
    }
}
NSString* point(int i, int j){
    if(i>=0&&i<H&&j>=0&&j<W){
        return [NSString stringWithFormat:@"%d %d",i,j];
    }
    return nil;
}
int main(){
    @autoreleasepool {
        scanf("%d %d",&H,&W);
        NSMutableSet *visitedPoints = [NSMutableSet set];
        NSMutableSet *nextPoints = [NSMutableSet set];
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                char c = getchar();
                if(c=='\n'){
                    c = getchar();
                }
                if(c=='#'){
                    addToSet(point(i,j), visitedPoints);
                    addToSetIfNotVisited(point(i-1,j), nextPoints, visitedPoints);
                    addToSetIfNotVisited(point(i+1,j), nextPoints, visitedPoints);
                    addToSetIfNotVisited(point(i,j-1), nextPoints, visitedPoints);
                    addToSetIfNotVisited(point(i,j+1), nextPoints, visitedPoints);
                }
            }
        }
        
        int ans=0;
        while([visitedPoints count]<H*W){
            NSMutableSet *nextnextPoints = [NSMutableSet set];
            [visitedPoints unionSet:nextPoints];
            for (NSString *p in nextPoints){
                NSArray *a = [p componentsSeparatedByString:@" "];
                int i = [[a objectAtIndex:0] intValue];
                int j = [[a objectAtIndex:1] intValue];
                addToSetIfNotVisited(point(i-1,j), nextnextPoints, visitedPoints);
                addToSetIfNotVisited(point(i+1,j), nextnextPoints, visitedPoints);
                addToSetIfNotVisited(point(i,j-1), nextnextPoints, visitedPoints);
                addToSetIfNotVisited(point(i,j+1), nextnextPoints, visitedPoints);
            }
            nextPoints = nextnextPoints;
            ans++;
        }
        printf("%d",ans);
    }
}
