#include<stdio.h>
#include<limits.h>
#include<queue>
struct S{int x,y,c;S(int x,int y,int c):x(x),y(y),c(c){}bool operator<(const S&r)const{return c>r.c;}};
int main()
{
	int w,h,x,y,d[]={0,1,0,-1,0},i;
	char*p,m[102][105];
	while(scanf("%d%d",&w,&h),w)
	{
		int f[102][102]={0};
		for(y=1;y<=h;++y)scanf("%s",m[y]+1);
		h+=2,w+=2;
		for(y=0;y<h;++y)m[y][0]=m[y][w-1]='.';
		for(x=0;x<w;++x)m[0][x]=m[h-1][x]='.';
		std::priority_queue<S>q;
		q.push(S(0,0,0));
		while(!q.empty())
		{
			S p(q.top());q.pop();
			char c=m[p.y][p.x];
			if(c=='&')
			{
				printf("%d\n",p.c);
				break;
			}
			for(i=0;i<4;++i)
			{
				x=p.x+d[i];
				y=p.y+d[i+1];
				if(x<0||w<=x||y<0||h<=y||f[y][x])continue;
				f[y][x]=1;
				char d=m[y][x];
				if(d=='#'&&d-c)q.push(S(x,y,p.c+1));
				else q.push(S(x,y,p.c));
			}
		}
	}
	return 0;
}