#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<int,P>PP;//wall y x
int M,N,mv[5]={-1,0,1,0,-1},res;
char A[105][105],B[105][105];
int d[105][105];
priority_queue<PP>Q;//need finit

void Pset(int y,int x)
{
	d[y][x]=0;
	Q.push(make_pair(0,make_pair(y,x)));
}

int main()
{
	for(;scanf("%d%d\n",&N,&M),N+M;)
	{
		res=100000000;
		memset(d,0x7f,sizeof(d));
		for(int i=0;i<=M+1;i++)for(int j=0;j<=N+1;j++)B[i][j]='.';
		for(int i=0;i<M;i++)gets(B[i+1]+1);
		for(int i=0;i<=M+1;i++){B[i][N+1]='.';B[i][N+2]=0;}
		N++;M++;
		Q.push(make_pair(0,make_pair(0,0)));
		while(!Q.empty())
		{
			PP tmp=Q.top();Q.pop();
			int y=tmp.second.first;
			int x=tmp.second.second;
			int cost=tmp.first;
			if(d[y][x]<cost)continue;
			if(B[y][x]=='&')
			{
				res=min(res,cost);
				continue;
			}
			for(int i=0;i<4;i++)
			{
				int ny=y+mv[i];
				int nx=x+mv[i+1];
				if(ny<0||ny>M||nx<0||nx>N)continue;
				int nc=cost+(B[y][x]=='#'&&B[ny][nx]!='#');
				if(nc<d[ny][nx])
				{
					d[ny][nx]=nc;
					Q.push(make_pair(nc,make_pair(ny,nx)));
				}
			}
		}
		printf("%d\n",res);
	}
}