# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<" :"<<x<<endl;
# define EPS 1e-12
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };



int main()
{
	int x, y;
	while (cin >> x >> y&&x)
	{
		int a[200][200] = {};
		int f[200][200];
		memset(f, -1, sizeof f);
		pii s;
		for (int i = 1; i <= y; i++)
		{
			for (int j = 1; j <= x; j++)
			{
				char c; cin >> c;
				a[i][j] = c == '#';
				if (c == '&')
				{
					s.first = i;
					s.second = j;
				}
				f[i][j] = INT_MAX;
			}
		}
		
		f[s.first][s.second] = 0;
		queue<pii> que; que.push(s);
		while (!que.empty())
		{
			pii now = que.front(); que.pop();
			for (int i = 0; i < 4; i++)
			{
				pii next = now;
				next.first += dy[i];
				next.second += dx[i];
				if (f[next.first][next.second]>f[now.first][now.second]+(a[now.first][now.second]&&!a[next.first][next.second]) )
				{
					f[next.first][next.second] = f[now.first][now.second] + (a[now.first][now.second] && !a[next.first][next.second]);
					que.push(next);
				}
			}
		}


		int ans = INT_MAX;
		for (int i = 1; i <= y; i++)ans = min({ ans,f[i][1]+a[i][1],f[i][x]+a[i][x] });
		for (int j = 1; j <= x; j++)ans = min({ ans,f[1][j]+a[1][j],f[y][j]+a[y][j] });;
		cout << ans << endl;
	}
}