#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
int main() {
  int n, m;
  while (cin >> n >> m, n || m) {
    int cx, cy;
    char ba[n + 2][m + 2];
    memset(ba, '.', sizeof(ba));
    for (int y = 1; y <= m; ++y) {
      for (int x = 1; x <= n; ++x) {
        cin >> ba[x][y];
        if (ba[x][y] == '&') {
          cx = x;
          cy = y;
        }
      }
    }
    int ans[n][m];
    memset(ans, -1, sizeof(ans));
    priority_queue<pair<int, pair<int, int> >,
                   vector<pair<int, pair<int, int> > >,
                   greater<pair<int, pair<int, int> > > >
        Q;
    Q.push(pair<int, pair<int, int> >(0, pair<int, int>(0, 0)));
    while (!Q.empty()) {
      pair<int, pair<int, int> > nwP = Q.top();
      Q.pop();
      pair<int, int> nwp = nwP.second;
      int x = nwp.first, y = nwp.second;
      if (ans[x][y] >= 0) continue;
      ans[x][y] = nwP.first;
      for (int k = 0; k < (int)4; ++k) {
        int xx = x + dx[k], yy = y + dy[k];
        if (ans[xx][yy] >= 0 || xx < 0 || n <= xx || yy < 0 || m <= yy)
          continue;
        if (ba[x][y] == '#' && ba[xx][yy] != '#') {
          Q.push(pair<int, pair<int, int> >(nwP.first + 1,
                                            pair<int, int>(xx, yy)));
        } else {
          Q.push(pair<int, pair<int, int> >(nwP.first, pair<int, int>(xx, yy)));
        }
      }
    }
    cout << ans[cx][cy] << endl;
  }
}
