#include <iostream>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

typedef pair<int,int> P;
struct St{
	int x, y, c;
	St(int cst, P p): c(cst), y(p.first), x(p.second) {}
	bool operator>(const St &s) const{
		return c > s.c;
	}
};

const int inf = 999999;
int xdir[4] = {0, -1, 0, 1}, ydir[4] = {1, 0, -1, 0};
int bfs(char a[101][101], int w, int h, P p)
{
	int r = -1, vis[101][101];
	priority_queue<St, vector<St>, greater<St> > que;
	fill(&vis[0][0], &vis[h][w], inf);
	vis[p.first][p.second] = 0;
	que.push(St(0, p));
	while(!que.empty()){
		St s = que.top();
		que.pop();
		if(s.x < 0 || s.x >= w || s.y < 0 || s.y >= h){
			r = s.c;
			break;
		}
		
		for(int i = 0; i < 4; i++){
			int dy = s.y+ydir[i], dx = s.x+xdir[i];
			if(dy < 0 || dy >= h || dx < 0 || dx >= w){
				St t = (a[s.y][s.x] == '#')? St((s.c+1), P(dy, dx)): St(s.c, P(dy, dx));
				que.push(t);
			} else if(vis[dy][dx] > s.c){
				int u = inf;
				if(a[s.y][s.x] == '#' && a[dy][dx] == '.'){
					u = s.c+1;
				} else {
					u = s.c;
				}
				if(u < vis[dy][dx]){
					vis[dy][dx] = u;
					que.push(St(u, P(dy, dx)));
				}
			}
		}
	}
	
	return r;
}

int main()
{
	int w, h;
	char a[101][101];
	P p;
	
	while(cin>>w>>h && (w+h)){
		for(int i =0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin >> a[i][j];
				if(a[i][j] == '&'){
					p = P(i, j);
					a[i][j] = '.';
				}
			}
		}
		
		cout << bfs(a, w, h, p) << endl;
	}
	
	return 0;
}