import std.stdio,std.string,std.array;

struct Point {int x,y;}

string[111] s;
Point[] q;
int[] dx = [0, 1, 0, -1];
int[] dy = [-1, 0, 1, 0];
int[111][111] cost; 

void main(){
	Point p;
	int n, m, sx, sy, tx, ty, newCost;
	while (readf("%d %d\n", &n, &m), n + m > 0) {
		n += 2;
		m += 2;
		s[0] = s[m-1] = [];
		foreach (x; 0..n) s[0] ~= '.';
		s[m-1] = s[0];
		cost[0] = cost[m-1] = 99999999;
		foreach (y; 1..m-1) {
			s[y] = '.' ~ readln.chomp ~ '.';
			cost[y] = 99999999;
			foreach (x; 1..n-1) {
				if (s[y][x] == '&') {
					sx = x;
					sy = y;
				}
			}
		}
		// solve by BFS
		cost[sy][sx] = 0;
		q ~= Point(sx, sy);
		while (!q.empty) {
			p = q.front;
			q.popFront();
			foreach (i; 0..4) {
				tx = dx[i] + p.x;
				ty = dy[i] + p.y;
				if (tx < 0 || ty < 0 || tx >= n || ty >= m) continue;
				newCost = cost[p.y][p.x] + (s[ty][tx] == '#' ? 1 : 0);
				if (cost[ty][tx] > newCost){
					cost[ty][tx] = newCost;
					q ~= Point(tx, ty);
				}
			}
		}
		writeln(cost[0][0]);
	}
}