#include <bits/stdc++.h>
using namespace std;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
class Data {
 public:
  int y;
  int x;
  int cnt;
  Data() {}
  Data(int _y, int _x, int _cnt) {
    y = _y;
    x = _x;
    cnt = _cnt;
  }
  bool operator<(const Data &a) const {
    if (cnt != a.cnt) return cnt > a.cnt;
    return y > a.y;
  }
};
int main() {
  int w, h;
  while (scanf("%d%d", &w, &h), w) {
    char stage[128][128];
    bool memo[128][128] = {{0}};
    for (int i = (0); i < (h + 2); i++) {
      for (int j = (0); j < (w + 2); j++) {
        stage[i][j] = '.';
      }
    }
    for (int i = (0); i < (h); i++) {
      scanf("%s", stage[i + 1] + 1);
      stage[i + 1][w + 1] = '.';
      stage[i + 1][w + 2] = '\0';
    }
    h += 2;
    w += 2;
    int ans = -1;
    priority_queue<Data> Q;
    Q.push(Data(0, 0, 0));
    memo[0][0] = 1;
    while (!Q.empty()) {
      Data d = Q.top();
      Q.pop();
      if (stage[d.y][d.x] == '&') {
        ans = d.cnt;
        break;
      }
      for (int i = (0); i < (4); i++) {
        int ny = d.y + dy[i];
        int nx = d.x + dx[i];
        if (ny < 0 || ny > h - 1 || nx < 0 || nx > w - 1 || memo[ny][nx] == 1)
          continue;
        memo[ny][nx] = 1;
        if (stage[ny][nx] == '#')
          Q.push(Data(ny, nx, d.cnt + 1));
        else
          Q.push(Data(ny, nx, d.cnt));
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
