#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<P,P>PP;//wall dist y x
int M,N,mv[5]={-1,0,1,0,-1},res;
char B[105][105];
P d[105][105];

struct Order
{
	bool operator ()(PP const&a, PP const&b) const
	{
		if(a.first.first==b.first.first)
			return a.first.second>b.first.second;
		return a.first.first>b.first.first;
	}
};

priority_queue<PP,vector<PP>,Order>Q; //need finit

void Pset(int y, int x)
{
	d[y][x]=make_pair(0,0);
	Q.push(make_pair(make_pair(0,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(make_pair(0,0),make_pair(0,0)));
		while (!Q.empty())
		{
			PP tmp=Q.top();Q.pop();
			int y=tmp.second.first;
			int x=tmp.second.second;
			P cost=tmp.first;
			if (d[y][x]<cost)continue;
			if (B[y][x]=='&' )
			{
				res=min(res,cost.first);
				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;
				P nc=make_pair(cost.first+(B[y][x]=='#' &&B[ny][nx]!= '#'),cost.second+1);
				if (nc<d[ny][nx])
				{
					d[ny][nx]=nc;
					Q.push(make_pair(nc,make_pair(ny,nx)));
				}
			}
		}
		printf( "%d\n" ,res);
	}
}
  