#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

struct STATE
{
	int x, y, d;
	bool operator<(const STATE &t)const{
		return d > t.d;
	}
};

char grid[128][128];
int d[128][128];

bool ingrid(int x, int y, int w, int h)
{
	return x >= 0 && x <= h + 1 && y >= 0 && y <= w + 1;
}

int main()
{
	int w, h;
	while (scanf("%d %d", &w, &h), w + h){
		memset(grid, '.', sizeof(grid));
		for (int i = 0; i < 128; i++){
			for (int j = 0; j < 128; j++){
				d[i][j] = INF;
			}
		}

		int sx, sy;
		for (int i = 1; i <= h; i++){
			for (int j = 1; j <= w; j++){
				scanf(" %c", &grid[i][j]);
				if (grid[i][j] == '&'){
					sx = i;
					sy = j;
				}
			}
		}
		
		int res = 0;
		priority_queue<STATE> que;
		for (que.push({sx, sy, 0}); !que.empty(); que.pop()){
			STATE st = que.top();
			if (d[st.x][st.y] <= st.d) continue;
			d[st.x][st.y] = st.d;
			if (st.x == 0 || st.y == 0 || st.x == h + 1 || st.y == w + 1){
				res = st.d;
				break;
			}
			for (int dir = 0; dir < 4; dir++){
				int tx = st.x + dx[dir];
				int ty = st.y + dy[dir];
				if (!ingrid(tx, ty, w, h)) continue;
				if (d[tx][ty] > st.d + (grid[st.x][st.y] == '#')){
					que.push({tx, ty, st.d + (grid[st.x][st.y] == '#' && grid[tx][ty] == '.')});
				}
			}
		}
		printf("%d\n", res);
	}
	
	return 0;
}