#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

char field[101][101];
bool passed[101][101];

const int dy[]={-1,0,0,1};
const int dx[]={0,-1,1,0};

int h,w;
// ×ÚÇÀWÌXg
set<pair<int,int> > walls;
set<pair<int,int> > spList;


bool bfs(int sx,int sy,bool w){
	// Ü¸ÊÉbfs
	queue<pair<int,int> > *prv=new queue<pair<int,int> >();
	queue<pair<int,int> > *nxt=new queue<pair<int,int> >();
	
	prv->push(make_pair(sy,sx));
	bool fin=false;
	passed[sy][sx]=true;
	while(prv->size()){
		while(prv->size()){
			pair<int,int> p = prv->front();
			prv->pop();
			// ÇÉBµ½çAI¹
			if(p.first==0||p.first==h-1||p.second==0||p.second==w-1){
				return true;
			}
			// lûüÉÚ®
			for(int i = 0; i < 4; i++){
				int nx=p.second+dx[i];
				int ny=p.first+dy[i];
				if(!passed[ny][nx]){
					if(w){
						if(field[ny][nx]=='.'){
							nxt->push(make_pair(ny,nx));
							passed[ny][nx]=true;
						}
						else if(field[ny][nx]=='#'){
							walls.insert(make_pair(ny,nx));
						}
					}
					else{
						if(field[ny][nx]=='#'){
							nxt->push(make_pair(ny,nx));
							passed[ny][nx]=true;
						}
						else if(field[ny][nx]='.'){
							spList.insert(make_pair(ny,nx));
						}
					}
				}
			}
		}
		swap(prv,nxt);
	}
	return false;
}

int main(){

	// ÇÉÕË·éÜÅbfsðJè©¦·
	while(cin>>w>>h&&!(w==0&&h==0)){
		walls.clear();
		spList.clear();
		int sx,sy;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin>>field[i][j];
				if(field[i][j]=='&')
					sx=j,sy=i;
			}
			fill(passed[i],passed[i]+w,false);
		}
		int cnt=0;
		bool fin=false;
		spList.insert(make_pair(sy,sx));
		while(1){
			// ÇÀWÌXgªèÉüéÌÅA»ÌÇÀW©çBÅ«éêðTõ
			for(set<pair<int,int> >::iterator it = spList.begin(); it != spList.end(); it++){
				int cx=it->second;
				int cy=it->first;
				if(bfs(cx,cy,true)){
					fin=true;
					break;
				}
			}
			if(fin)
				break;
			spList.clear();
			cnt++;
			// ÇðÂ½ÁÄ¢¯éªðTõµA»ÌãÇÉ×Ú·éÀWðÛµÄ¨«A[v
			for(set<pair<int,int> >::iterator it = walls.begin(); it != walls.end(); it++){
				int cx=it->second;
				int cy=it->first;
				if(bfs(cx,cy,false)){
					fin=true;
					break;
				}
			}
			if(fin)
				break;
			walls.clear();
		}
		cout<<cnt<<endl;
	}

	return 0;
}