#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int X, Y;
  while (cin >> Y >> X) {
    vector<string> G(Y+2, string(X+2, '-'));
    for (int y = 1; y <= Y; y++) for (int x = 1; x <= X; x++) cin >> G[y][x];

    int ret = 0;
    vector<vector<int>> dist(Y+2, vector<int>(X+2, -1));
    vector<pair<int, int>> q;
    for (int y = 0; y < G.size(); y++) for (int x = 0; x < G[0].size(); x++) {
      if (G[y][x] == '-') q.push_back({x, y});
    }
    for (int d = 0; q.size(); d++) {
      vector<pair<int, int>> q2;
      for (auto [x, y] : q) {
        if (dist[y][x] != -1) continue;
        dist[y][x] = d;
        ret = max(ret, d);
        if (x >  0) q2.push_back({x-1, y  });
        if (x <= X) q2.push_back({x+1, y  });
        if (y >  0) q2.push_back({x  , y-1});
        if (y <= Y) q2.push_back({x  , y+1});
      }
      q.swap(q2);
    }
    cout << ret << endl;
  }
}
