#include<iostream>
#include<algorithm>
using namespace std;

int n,m;
string grid[100];
int dis[100][100];

void dfs(int y, int x, int mode){
  int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};
  for(int i=0;i<4;i++){
    int sx = x + dx[i], sy = y+dy[i];
    if(sx<0 || sy<0 || m<=sy || n<=sx)continue;
    if(mode){
      if(dis[sy][sx] < 0){
	if(grid[sy][sx] == '#'){
	  dis[sy][sx] = dis[y][x];
	  dfs(sy,sx,mode);
	}
	if(grid[sy][sx] == '.')dis[sy][sx] = dis[y][x];
      }
    }else{
      if(dis[sy][sx] < 0){
	if(grid[sy][sx] == '.'){
	  dis[sy][sx] = dis[y][x];
	  dfs(sy,sx,mode);
	}
	if(grid[sy][sx] == '#')dis[sy][sx] = dis[y][x] + 1;
      }
    }
  }
}

int main(){
  while(1){
    cin >> n >> m;
    if(!n && !m)break;

    for(int i=0;i<m;i++)cin >> grid[i];
    
    for(int i=0;i<m;i++)
      for(int j=0;j<n;j++)
	dis[i][j] = -1;
    
    for(int i=0;i<m;i++)
      for(int j=0;j<n;j++)
	if(grid[i][j] == '&'){
	  dis[i][j] = 0;
	  grid[i][j] = '.';
	}
    
    int cnt = 0;
    while(1){
      bool f = false;
      for(int i=0;i<m;i++)
	for(int j=0;j<n;j++)
	  if(dis[i][j] == cnt && grid[i][j] == '.'){
	    dfs(i,j,0);
	    f = true;
	  }
      
      cnt++;

      for(int i=0;i<m;i++)
	for(int j=0;j<n;j++)
	  if(dis[i][j] == cnt && grid[i][j] == '#'){
	    dfs(i,j,1);
	    f = true;
	  }
      if(!f)break;
    }
    
    int ans = 10000;
    for(int i=0;i<m;i++)
      for(int j=0;j<n;j++)
	if(!i || !j || i==m-1 || j==n-1)ans = min(ans,dis[i][j]);
    
    cout << ans << endl;
  }
}