#include <iostream>
#include <deque>
using namespace std;

struct NODE{
	int x,y,c;
	NODE(int x,int y,int c):x(x),y(y),c(c){}
	
};
char c[102][102];
int main(){
	int H,W;
	while(cin >> W >> H && W){
		int sx , sy;
		for(int i = 0 ; i <= H+1 ; i++)
			for(int j = 0 ; j <= W+1 ; j++)
				c[i][j] = '.';

		for(int i = 1 ; i <= H ; i++){
			for(int j = 1 ; j <= W ; j++){
				cin >> c[i][j];
				if(c[i][j] == '&'){
					sx = j , sy = i;
				}
			}
		}

		int dx[] = {-1,0,1,0};
		int dy[] = {0,1,0,-1};
		deque<NODE> Q;
		int memo[102][102] = {} ;
		Q.push_back(NODE(sx,sy,0));
		memo[sy][sx] = 1;
		while(Q.size()){
			NODE q = Q.front(); Q.pop_front();
			if(q.x == W+1 || q.x == 0 || q.y == H+1 || q.y == 0){
				cout << q.c << endl;
				break;
			}
			for(int i = 0 ; i < 4 ; i++){
				int tx = q.x + dx[i];
				int ty = q.y + dy[i];
				if(memo[ty][tx]) continue;
				if( c[q.y][q.x] != '#' && c[ty][tx] == '#' ){
					Q.push_back(NODE(tx,ty,q.c+1));
				}else{
					Q.push_front(NODE(tx,ty,q.c));
				}
				memo[ty][tx] = true;
			}
		}
		
	}
}