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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1 << 20

using namespace std;

int main()
{
	vector<string> s(100);
	int ans,h,w,sx,sy;
	int dx[4] = {1,0,-1,0};
	int dy[4] = {0,1,0,-1};
	int cost[100][100];
	
	while(cin >> w >> h)
	{
		if(w == 0 && h == 0) break;
		
		rep(i,h) rep(j,w) cost[i][j] = INF;
		ans = INF;

		rep(i,h)
		{
			cin >> s[i];
		}
		
		rep(i,h)
		{
			rep(j,w)
			{
				if(s[i][j] == '&')
				{
					sy = i;
					sx = j;
				}
			}
		}

		cost[sy][sx] = 0;

		queue<pair<int,int> > que;
		que.push(make_pair(sy,sx));

		while(!que.empty())
		{
			pair<int,int> p = que.front();
			int y = p.first;
			int x = p.second;
			que.pop();

			rep(i,4)
			{
				int ny = y + dy[i];
				int nx = x + dx[i];

				if(0 <= ny && ny < h && 0 <= nx && nx < w)
				{
					int temp = cost[y][x];
					if(s[y][x] != '#' && s[ny][nx] == '#')
					{
						temp++;
					}

					if(temp < cost[ny][nx])
					{
						cost[ny][nx] = temp;
						que.push(make_pair(ny,nx));
					}
				}
			}
		}

		rep(i,h)
		{
			rep(j,w)
			{
				if(i == 0 || i == h-1 || j == 0 || j == w-1)
				{
					ans = min(ans,cost[i][j]);
				}
			}
		}
	
		cout << ans << endl;
	}
}