#include<queue>
#include<cstdio>

#define	mp	make_pair

using namespace std;

typedef	pair<int,int>	pii;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
char field[100][101];
int w,h,memo[100][100];

int main(){
	for(;scanf("%d%d",&w,&h),w;){
		for(int i=0;i<h;i++)	scanf("%s",field[i]);

		int sx,sy;
		for(int i=0;i<h;i++)for(int j=0;j<w;j++){
			if(field[i][j]=='&')	sy=i,sx=j,field[i][j]='.';
			memo[i][j]=1<<30;
		}

		int ans;
		memo[sy][sx]=0;
		priority_queue< pair<int,pii> > pq;	pq.push(mp(0,mp(sy,sx)));
		while(1){
			pair<int,pii> a=pq.top();	pq.pop();
			int cost=-a.first,x=a.second.second,y=a.second.first;
			if(x==0 || x==w-1 || y==0 || y==h-1){ ans=cost; break; }
			for(int i=0;i<4;i++){
				int xx=x+dx[i],yy=y+dy[i],nextcost;
				if(0<=xx && xx<w && 0<=yy && yy<h){
					if(field[y][x]=='.' && field[yy][xx]=='#')	nextcost=cost+1;
					else	nextcost=cost;
					if(nextcost<memo[yy][xx]){
						memo[yy][xx]=nextcost;
						pq.push(mp(-nextcost,mp(yy,xx)));
					}
				}
			}
		}

		printf("%d\n",ans);
	}

	return 0;
}