#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

const int INF = 1000000000;

int h, w;
char mapData[100][100];
bool visited[100][100];
bool visited2[100][100];
int gx, gy;
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
int height[100][100];
int valm;

void dfs(int y, int x){
  valm = min(valm, height[y][x]);
  for(int i=0;i<4;i++){
    int ty = y + dy[i];
    int tx = x + dx[i];
    if(ty < 0 || ty >= h) continue;
    if(tx < 0 || tx >= w) continue;
    if(mapData[ty][tx] == '#') continue;
    if(visited[ty][tx]) continue;
    visited[ty][tx] = true;
    dfs(ty, tx);
  }
}

void dfs2(int y, int x){
  height[y][x] = valm;
  for(int i=0;i<4;i++){
    int ty = y + dy[i];
    int tx = x + dx[i];
    if(ty < 0 || ty >= h) continue;
    if(tx < 0 || tx >= w) continue;
    if(mapData[ty][tx] == '#') continue;
    if(visited2[ty][tx]) continue;
    visited2[ty][tx] = true;
    dfs2(ty, tx);
  }
}

int solve(){
  fill(height[0], height[100], INF);
  int cnt;
  for(int j=0;j<w;j++){//top to bottom
    cnt = 0;
    for(int i=0;i<h;i++){
      if(mapData[i][j] == '#'){
	height[i][j] = -1;
	cnt++;
      }
      height[i][j] = min(height[i][j], cnt);
    }
  }
  for(int i=0;i<h;i++){//left to right
    cnt = 0;
    for(int j=w-1;j>=0;j--){
      if(mapData[i][j] == '#'){
	height[i][j] = -1;
	cnt++;
      }
      height[i][j] = min(height[i][j], cnt);
    }
  }
  for(int j=0;j<w;j++){//bottom to top
    cnt = 0;
    for(int i=h-1;i>=0;i--){
      if(mapData[i][j] == '#'){
	height[i][j] = -1;	
	cnt++;
      }
      height[i][j] = min(height[i][j], cnt);
    }
  }
  for(int i=0;i<h;i++){//right to left
    cnt = 0;
    for(int j=0;j<w;j++){
      if(mapData[i][j] == '#'){
	height[i][j] = -1;
	cnt++;
      }
      height[i][j] = min(height[i][j], cnt);
    }
  }
  fill(visited[0], visited[100], false);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(mapData[i][j] == '#' || visited[i][j]) continue;
      valm = INF;
      dfs(i, j);
      fill(visited2[0], visited2[100], false);
      dfs2(i, j);
    }
  }
  return height[gy][gx];
}

main(){
  while(cin >> w >> h && (h || w)){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> mapData[i][j];
	if(mapData[i][j] == '&'){
	  mapData[i][j] = '.';
	  gy = i;
	  gx = j;
	}
      }
    }
    cout << solve() << endl;
    /*for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cout << setw(2) << height[i][j];
      }
      cout << endl;
      }*/
  }
  return 0;
}