// 2011/08/26 Tazoe

#include <iostream>
using namespace std;

void DFS(char M[104][104], int y, int x, int C[104][104], int c)
{
	C[y][x] = c;

	if(M[y-1][x]=='.'&&C[y-1][x]==-1)
		DFS(M, y-1, x, C, c);
	if(M[y+1][x]=='.'&&C[y+1][x]==-1)
		DFS(M, y+1, x, C, c);
	if(M[y][x-1]=='.'&&C[y][x-1]==-1)
		DFS(M, y, x-1, C, c);
	if(M[y][x+1]=='.'&&C[y][x+1]==-1)
		DFS(M, y, x+1, C, c);
}

void DFS2(char M[104][104], int y, int x, int C[104][104], int c)
{
	C[y][x] = c;

	if(M[y-1][x]=='.'&&C[y-1][x]==-1)
		DFS(M, y-1, x, C, c);
	if(M[y+1][x]=='.'&&C[y+1][x]==-1)
		DFS(M, y+1, x, C, c);
	if(M[y][x-1]=='.'&&C[y][x-1]==-1)
		DFS(M, y, x-1, C, c);
	if(M[y][x+1]=='.'&&C[y][x+1]==-1)
		DFS(M, y, x+1, C, c);

	if(M[y-1][x]=='#'&&C[y-1][x]==-1)
		DFS2(M, y-1, x, C, c);
	if(M[y+1][x]=='#'&&C[y+1][x]==-1)
		DFS2(M, y+1, x, C, c);
	if(M[y][x-1]=='#'&&C[y][x-1]==-1)
		DFS2(M, y, x-1, C, c);
	if(M[y][x+1]=='#'&&C[y][x+1]==-1)
		DFS2(M, y, x+1, C, c);
}

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;
		if(n==0&&m==0)
			break;

		char M[104][104];
		for(int y=0; y<=m+3; y++)
			for(int x=0; x<=n+3; x++)
				M[y][x] = '#';
		for(int y=1; y<=m+2; y++)
			for(int x=1; x<=n+2; x++)
				M[y][x] = '.';

		int Y = -1;
		int X = -1;
		for(int y=2; y<=m+1; y++){
			for(int x=2; x<=n+1; x++){
				cin >> M[y][x];
				if(M[y][x]=='&'){
					Y = y;
					X = x;
					M[y][x] = '.';
				}
			}
		}
//		cout << Y << ' ' << X << endl;

		int C[104][104];
		for(int y=0; y<=m+3; y++)
			for(int x=0; x<=n+3; x++)
				C[y][x] = -1;

		int cnt = 0;
		DFS(M, Y, X, C, cnt);

		if(C[1][1]!=-1){
			cout << C[1][1] << endl;
			continue;
		}

	while(true){
		cnt++;
		for(int y=2; y<=m+1; y++){
			for(int x=2; x<=n+1; x++){
				if(M[y][x]=='#'&&C[y][x]==-1&&M[y-1][x]=='.'&&C[y-1][x]==cnt-1)
					DFS2(M, y, x, C, cnt);
				if(M[y][x]=='#'&&C[y][x]==-1&&M[y+1][x]=='.'&&C[y+1][x]==cnt-1)
					DFS2(M, y, x, C, cnt);
				if(M[y][x]=='#'&&C[y][x]==-1&&M[y][x-1]=='.'&&C[y][x-1]==cnt-1)
					DFS2(M, y, x, C, cnt);
				if(M[y][x]=='#'&&C[y][x]==-1&&M[y][x+1]=='.'&&C[y][x+1]==cnt-1)
					DFS2(M, y, x, C, cnt);
			}
		}

		if(C[1][1]!=-1){
			cout << C[1][1] << endl;
			break;
		}
	}
/*
		for(int y=0; y<=m+3; y++){
			for(int x=0; x<=n+3; x++){
				if(C[y][x]==-1)
					cout << '-';
				else
					cout << C[y][x];
			}
			cout << endl;
		}
*/
	}

	return 0;
}