#include <iostream>
#include <queue>
#include <cstring>
#define rep(i,n) for(int i=0;i<(n);i++)

const int INF = 1 << 30;

using namespace std;

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

char M[105][105];
int v[105][105];

int bfs (int m, int n, P sp )
{
	const int dir[][2] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } };
	priority_queue<PP, vector <PP>, greater<PP> > que;
	que.push (PP(0, sp ) );
	
	while (!que.empty() ){
		PP curr = que.top(); que.pop();
		int cost = curr.first;
		int cr = curr.second.first, cc = curr.second.second;
		if (v[cr][cc] > cost ) 
			v[cr][cc] = cost;
		else
			continue;
		rep (k, 4 ){
			int nr = cr + dir[k][0], nc = cc + dir[k][1];
			if (nr < 0 || nr > m+1 || nc < 0 || nc > n+1 )
				return cost;
			if (M[cr][cc] == '.' && M[nr][nc] == '#' ){
				que.push ( PP (cost+1, P (nr, nc ) ) );
			}else{
				que.push ( PP (cost, P (nr, nc ) ) );
			} // end if
		} // end rep
	} // end while

	return -1;
}
 
void init_map (int m, int n )
{
	rep (i, m+2 )
		rep (j, n+2 ){
			M[i][j] = '.';
			v[i][j] = INF;
		} // end rep
}
int main()
{
	int n, m;	// n: ¼Ì m: ìkÌ 

	while (cin >> n >> m && n && m ){
		P sp;
		init_map (m, n );	
		for (int i = 1; i <= m; i++ ){
			for (int j = 1; j <= n; j++ ){
				cin >> M[i][j];
				if (M[i][j] == '&' ){
					sp.first = i, sp.second = j;
				} // end if
			} // end for
		} // end for
		int res = bfs (m, n, sp );
		cout << res << endl;
	} // end loop
		
	return 0;
}