#include <bits/stdc++.h>
using namespace std;
int dis[110][110], p[110][110];
priority_queue<pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >,
               greater<pair<int, pair<int, int> > > >
    Q;
void Qpush(int a, int b, int c) { Q.push(make_pair(a, make_pair(b, c))); }
int main() {
  int h, w;
  while (cin >> w >> h && h + w) {
    for (int i = 0; i < h; i++)
      for (int j = 0; j < w; j++) {
        char z;
        cin >> z;
        if (z == '&') Qpush(0, i, j);
        if (z == '#')
          p[i][j] = 1;
        else
          p[i][j] = 0;
        dis[i][j] = 1000000007;
      }
    while (!Q.empty()) {
      int cost = Q.top().first;
      int y = Q.top().second.first;
      int x = Q.top().second.second;
      Q.pop();
      if (dis[y][x] <= cost) continue;
      dis[y][x] = cost;
      int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
      for (int i = 0; i < 4; i++) {
        int xx = x + dx[i], yy = y + dy[i];
        if (xx < 0 || xx == w || yy < 0 || yy == h) continue;
        if (dis[yy][xx] > cost + p[yy][xx]) Qpush(cost + p[yy][xx], yy, xx);
      }
    }
    int ans = 1000000007;
    for (int i = 0; i < h; i++) ans = min(ans, min(dis[i][0], dis[i][w - 1]));
    for (int j = 0; j < w; j++) ans = min(ans, min(dis[0][j], dis[h - 1][j]));
    cout << ans << endl;
  }
  return 0;
}
