#include <iostream>
#include <string>
#include <queue>
#include <vector>
#define mp make_pair
#define INF 1e+9
using namespace std;

int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};

typedef pair<int,int> PP;
typedef pair<int,PP> P;

int main(){
	int n,m;
	while(cin >> m >> n,m){
		int sx,sy,d[100][100];
		string field[100];
		for(int i = 0;i < n;i++){
			cin >> field[i];
			for(int j = 0;j < m;j++){
				if(field[i][j] == '&'){
					sx = i;
					sy = j;
					d[i][j] = 0;
					field[i][j] = '.';
				}else d[i][j] = INF;
			}
		}
		priority_queue<P,vector<P>,greater<P> > que;
		que.push(mp(0,mp(sx,sy)));
		while(!que.empty()){
			P p = que.top();que.pop();
			int cost = p.first,x = p.second.first,y = p.second.second;
			if(d[x][y] < cost) continue;
			for(int i = 0;i < 4;i++){
				int nx = x + dx[i],ny = y + dy[i],next = d[x][y];
				if(nx >= 0 && nx < n && ny >= 0 && ny < m){
					if(field[nx][ny] == '.' && field[x][y] == '#') next++;
					if(d[nx][ny] > next){
						d[nx][ny] = next;
						que.push(mp(next,mp(nx,ny)));
					}
				}
			}
		}
		int mi = INF;
		for(int i = 0;i < n;i++){
			for(int j = 0;j < m;j++){
				if(!i || !j || i == n - 1 || j == m - 1) {
					if(field[i][j] == '#') d[i][j]++;
					mi = min(mi,d[i][j]);
				}
			}
		}
		cout << mi << endl;
	}
	return 0;
}