#include <bits/stdc++.h>
using namespace std;
char field[101][101];
bool passed[101][101];
const int dy[] = {-1, 0, 0, 1};
const int dx[] = {0, -1, 1, 0};
int h, w;
vector<pair<int, int> > walls;
vector<pair<int, int> > spList;
bool bfs(int sx, int sy, bool w) {
  queue<pair<int, int> > *prv = new queue<pair<int, int> >();
  queue<pair<int, int> > *nxt = new queue<pair<int, int> >();
  prv->push(make_pair(sy, sx));
  bool fin = false;
  while (prv->size()) {
    while (prv->size()) {
      pair<int, int> p = prv->front();
      prv->pop();
      passed[p.first][p.second] = true;
      if (p.first == 0 || p.first == h - 1 || p.second == 0 ||
          p.second == w - 1) {
        return true;
      }
      for (int i = 0; i < 4; i++) {
        int nx = p.second + dx[i];
        int ny = p.first + dy[i];
        if (!passed[ny][nx]) {
          if (w) {
            if (field[ny][nx] == '.')
              nxt->push(make_pair(ny, nx));
            else if (field[ny][nx] == '#') {
              walls.push_back(make_pair(ny, nx));
            }
          } else {
            if (field[ny][nx] == '#') {
              nxt->push(make_pair(ny, nx));
            } else if (field[ny][nx] = '.') {
              spList.push_back(make_pair(ny, nx));
            }
          }
        }
      }
    }
    swap(prv, nxt);
  }
  return false;
}
int main() {
  while (cin >> w >> h && !(w == 0 && h == 0)) {
    int sx, sy;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> field[i][j];
        if (field[i][j] == '&') sx = j, sy = i;
      }
      fill(passed[i], passed[i] + w, false);
    }
    int cnt = 0;
    bool fin = false;
    spList.push_back(make_pair(sy, sx));
    while (1) {
      for (int i = 0; i < spList.size(); i++) {
        int cx = spList[i].second;
        int cy = spList[i].first;
        if (bfs(cx, cy, true)) {
          fin = true;
          break;
        }
      }
      if (fin) break;
      spList.clear();
      for (int i = 0; i < walls.size(); i++) {
        int cx = walls[i].second;
        int cy = walls[i].first;
        if (bfs(cx, cy, false)) {
          fin = true;
          break;
        }
      }
      walls.clear();
      cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}
