#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
using namespace std;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};
#define INF 1e+8
#define EPS 1e-10
#define PB push_back
#define fi first
#define se second
#define ll long long 
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
typedef pair<int,int> Pii;
typedef vector<int> vi;
class Data{
	public:
	int y;
	int x;
	int cnt;
	Data(){}
	Data(int _y,int _x,int _cnt){
		y = _y;
		x = _x;
		cnt = _cnt;
	}
	bool operator<(const Data &a)const{
		if(cnt != a.cnt)return cnt > a.cnt;
		return y > a.y;
	}
};
int main(){
	int w,h;
	while(scanf("%d%d",&w,&h),w){
		char stage[128][128];
		bool memo[128][128]={{0}};
		rep(i,h+2){
			rep(j,w+2){
				stage[i][j] = '.';
			}
		}
		rep(i,h){
			scanf("%s",stage[i+1]+1);
			stage[i+1][w+1] = '.';
			stage[i+1][w+2] = '\0';
		}
		h += 2;
		w += 2;
		int ans = -1;
		priority_queue < Data > Q;
		Q.push(Data(0,0,0));
		memo[0][0] = 1;
		while( !Q.empty() ){
			Data d = Q.top();Q.pop();
			if(stage[d.y][d.x] == '&'){
				ans = d.cnt;
				break;	
			}
			rep(i,4){
				int ny = d.y + dy[i];
				int nx = d.x + dx[i];
				if(ny < 0 || ny > h-1 || nx < 0 || nx > w-1 || memo[ny][nx]==1)continue;
				memo[ny][nx]=1;
				if(stage[ny][nx] == '#')Q.push(Data(ny,nx,d.cnt+1));
				else Q.push(Data(ny,nx,d.cnt));
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}