#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

int n,m,ans;
char f[110][110];

int di[4]={0,0,1,-1};
int dj[4]={1,-1,0,0};

class Info{
public:
	int i,j,walk;
};

void bfs(int i,int j){
	int k,l,w[110][110];
	queue<Info> q;
	Info tmp = {i,j,0};

	if(f[i][j] == 'G'){ans = 0; return;}
	for(k=0;k<110;k++) for(l=0;l<110;l++) w[k][l] = 99999;

	w[i][j] = 0;
	ans = 99999;
	q.push(tmp);

	while(!q.empty()){
		tmp = q.front(); q.pop();

		for(int k=0;k<4;k++){
			int ni = tmp.i + di[k];
			int nj = tmp.j + dj[k];
			int nwalk = tmp.walk;

			if(f[tmp.i][tmp.j] == '.' && f[ni][nj] == '#') nwalk++;

			if(f[ni][nj] == 'G'){
				if(ans > tmp.walk) ans = tmp.walk;
			}
			else if(nwalk < w[ni][nj]){
				Info tmp2 = {ni,nj,nwalk};

				w[ni][nj] = nwalk;
				q.push(tmp2);
			}
		}
	}
}

void dfs(int i,int j){
	f[i][j] = 'G';
	for(int k=0;k<4;k++){
		int ni = i + di[k];
		int nj = j + dj[k];
		if(f[ni][nj] == '.') dfs(ni,nj);
	}
}

int main(void){
	int i,j,si,sj;

	while(cin>>n>>m && (n || m)){
		memset(f,'.',sizeof(f));
		for(i=1;i<=m;i++){
			for(j=1;j<=n;j++){
				cin>>f[i][j];
				if(f[i][j] == '&'){f[i][j]='.'; si=i; sj=j;}
			}
		}

		dfs(0,0);
		bfs(si,sj);

		cout<<ans<<endl;
	}

	return 0;
}