#include <bits/stdc++.h>
using namespace std;
int dx[]{1, -1, 0, 0}, dy[]{0, 0, 1, -1};
char f[200][200];
int d[200][200];
struct st {
  int x, y, c;
};
bool operator<(st a, st b) { return a.c > b.c; }
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m), n) {
    memset(f, '.', sizeof(f));
    int gx, gy;
    for (int i = 1; i <= m; i++) {
      scanf("%s", f[i] + 1);
      f[i][n + 1] = '.';
      for (int j = 1; j <= n; j++) {
        if (f[i][j] == '&') gx = i, gy = j;
      }
    }
    m++;
    n++;
    priority_queue<st> que;
    memset(d, 0x3f, sizeof(d));
    d[0][0] = 0;
    que.push({0, 0, 0});
    while (!que.empty()) {
      st p = que.top();
      que.pop();
      if (p.c != d[p.x][p.y]) continue;
      for (int i = 0; i < 4; i++) {
        int nx = p.x + dx[i], ny = p.y + dy[i];
        if (!(0 <= nx && nx <= m && 0 <= ny && ny <= n)) continue;
        if (f[nx][ny] == '#') {
          if (d[nx][ny] > p.c + 1) {
            d[nx][ny] = p.c + 1;
            que.push({nx, ny, d[nx][ny]});
          }
        } else {
          if (d[nx][ny] > p.c) {
            d[nx][ny] = p.c;
            que.push({nx, ny, d[nx][ny]});
          }
        }
      }
    }
    printf("%d\n", d[gx][gy]);
  }
}
