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

using namespace std;


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

const int INF = 1 << 30;

char Map[105][105];
int cost[105][105];

int bfs (P sp, int m, int n )
{
	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 c = curr.first;
		int cr = curr.second.first, cc = curr.second.second;
		if (cr == 0 || cr == m || cc == 0 || cc == n )
			return c;
		if (cost[cr][cc] > c ) cost[cr][cc] = c;
		else
			continue;
		rep (k, 4 ){
			int nr = cr + dir[k][0], nc = cc + dir[k][1];
			if (Map[cr][cc] == '.' && Map[nr][nc] == '#' ){
				que.push (PP(c+1, P (nr, nc ) ) );
			} // end if
			else{
				que.push (PP (c, P(nr, nc ) ) );
			} // end if
		} // end rep
	} // end while

	return -1;
} 

int main()
{
	int n, m;	// n: ¼Ì m: ìkÌ 

	while (cin >> n >> m && n && m ){
		memset (Map, 0, sizeof (Map ) );
		rep (i, m+2 )
			rep (j, n+2 )
				cost[i][j] = INF;

		P sp;	// VçtÌÊu

		rep (i, m ){
			rep (j, n ){
				cin >> Map[i][j];
			} // end rep
		} // end rep
		rep (i, m ){
			rep (j, n ){
				if (Map[i][j] == '&' ){
					sp.first = i, sp.second = j;
				} // end if
			} // end for
		} // end rep

		int res = bfs (sp, m, n );

		cout << res << endl;	
	} // end loop
		
	return 0;
}