#include <iostream>
#include <queue>
#include <algorithm>

using namespace std;

#define MAX 120
#define INF 1e9

int H, W;
char field[MAX][MAX];
const int dx[] = {-1,0,0,1};
const int dy[] = {0,-1,1,0};

bool inField(int y, int x){
  return 0 <= y && y < H && 0 <= x && x < W;
}

bool check(int y, int x){
  if(y == 0 || y == H-1) return true;
  if(x == 0 || x == W-1) return true;
  return false;
}

void bfs(int y, int x){
  int ans = INF;
  int cost[MAX][MAX];
  fill(cost[0], cost[MAX], INF);
  queue<int> nowx, nowy, cnt;
  nowx.push(x); nowy.push(y); cnt.push(0);

  while(!nowx.empty()){
    int xx = nowx.front(); nowx.pop();
    int yy = nowy.front(); nowy.pop();
    int c = cnt.front(); cnt.pop();

    for(int i = 0 ; i < 4 ; i++){
      int nx = xx + dx[i];
      int ny = yy + dy[i];

      if(!inField(ny, nx)) continue;
      if(check(ny, nx)){
        if(field[yy][xx] != '#' && field[ny][nx] == '#'){
          cost[ny][nx] = min(cost[ny][nx], c+1);
        }else{
          cost[ny][nx] = min(cost[ny][nx], c);
        }
        continue;
      }
      int nc = c;
      if(field[yy][xx] != '#' && field[ny][nx] == '#') nc++;
      if(nc < cost[ny][nx]){
        cost[ny][nx] = nc;
        nowx.push(nx); nowy.push(ny); cnt.push(nc);
      }
    }
  }
  for(int i = 0 ; i < H ; i++){
    ans = min(ans, cost[i][0]);
    ans = min(ans, cost[i][W-1]);
  }
  for(int i = 0 ; i < W ; i++){
    ans = min(ans, cost[0][i]);
    ans = min(ans, cost[H-1][i]);
  }

  cout << ans << endl;
}

int main(){
  int sx, sy;
  while(cin >> W >> H, (W | H)){
    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;
        }
      }
    }  
    bfs(sy, sx);
  }

  return 0;
}