#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
struct STATE {
  int x, y, d;
  bool operator<(const STATE &t) const { return d > t.d; }
};
char grid[128][128];
int d[128][128];
int main() {
  int w, h;
  while (scanf("%d %d", &w, &h), w + h) {
    memset(grid, '.', sizeof(grid));
    for (int i = 0; i < 128; i++) {
      for (int j = 0; j < 128; j++) {
        d[i][j] = INF;
      }
    }
    int sx, sy;
    for (int i = 1; i <= h; i++) {
      for (int j = 1; j <= w; j++) {
        scanf(" %c", &grid[i][j]);
        if (grid[i][j] == '&') {
          sx = i;
          sy = j;
        }
      }
    }
    int res = 0;
    queue<STATE> que;
    for (que.push({sx, sy, 0}); !que.empty(); que.pop()) {
      STATE st = que.front();
      if (d[st.x][st.y] <= st.d) continue;
      d[st.x][st.y] = st.d;
      if (st.x == 0 || st.y == 0 || st.x == h + 1 || st.y == w + 1) {
      }
      for (int dir = 0; dir < 4; dir++) {
        int tx = st.x + dx[dir];
        int ty = st.y + dy[dir];
        if (d[tx][ty] > st.d + (grid[st.d][st.d] == '#')) {
          que.push({tx, ty, st.d + (grid[st.x][st.y] == '#')});
        }
      }
    }
    printf("%d\n", d[0][0]);
  }
  return 0;
}
