#include <bits/stdc++.h>
int x, y;
int cost[100][100];
char map[100][101];
int getmin(int sy, int sx, int d) {
  int i;
  int ret = 100000;
  int dx[4] = {1, 0, -1, 0};
  int dy[4] = {0, 1, 0, -1};
  int mx, my;
  int temp;
  if (0 == sx || 0 == sy || x - 1 == sx || y - 1 == sy) {
    cost[my][mx] = d;
    return (cost[my][mx]);
  }
  for (i = 0; i < 4; i++) {
    mx = sx + dx[i];
    my = sy + dy[i];
    if (0 <= mx && mx < x && 0 <= my && my < y && cost[my][mx] > d) {
      cost[my][mx] = d;
      if (map[my][mx] == '#') {
        cost[my][mx]++;
        temp = getmin(my, mx, d + 1);
      } else {
        temp = getmin(my, mx, d);
      }
      ret = temp > ret ? ret : temp;
    }
  }
  return (ret);
}
int main(void) {
  int ans;
  int i, j;
  int sx, sy;
  while (1) {
    scanf("%d%d", &x, &y);
    if (x + y == 0) {
      break;
    }
    getchar();
    for (i = 0; i < y; i++) {
      for (j = 0; j < x; j++) {
        cost[i][j] = 100000;
        scanf("%c", &map[i][j]);
        if (map[i][j] == '&') {
          sx = j;
          sy = i;
        }
      }
      getchar();
    }
    cost[sy][sx] = 0;
    ans = getmin(sy, sx, 0);
    printf("%d\n", ans);
  }
  return (0);
}
