#include "bits/stdc++.h"
using namespace std;
#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(i=(j);(i)<(k);++i)
#define Y first
#define X second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int dx[] = { 0, -1, 0, 1 }, dy[] = { -1, 0, 1, 0 };

int main() {
	int n, m, i, j, d, res;
	while (scanf("%d%d", &n, &m) && n + m) {
		char cas[128][128];
		int cnt[128][128];
		rep(i, m)
			rep(j, n)
				cnt[i][j] = INF;
		rep(i, m)
			scanf("%s", cas[i]);
		int x, y;
		rep(i, m)
			rep(j, n)
				if (cas[i][j] == '&') {
					y = i;
					x = j;
				}
		cnt[y][x] = 0;
		cas[y][x] = '.';
		queue<pi> q;
		q.push(make_pair(y, x));
		while (!q.empty()) {
			int qsize = (int) q.size();
			rep(i, qsize)
			{
				pi now = q.front();
				q.pop();
				rep(d, 4)
				{
					int ny = now.Y + dy[d], nx = now.X + dx[d];
					if (ny < 0 || nx < 0 || ny >= m || nx >= n)
						continue;
					int cost =
							cnt[now.Y][now.X]
									+ ((cas[ny][nx] == '#'
											&& cas[now.Y][now.X] != '#') ? 1 : 0);
					if (cnt[ny][nx] <= cost)
						continue;
					cnt[ny][nx] = cost;
					q.push(make_pair(ny, nx));
				}
			}
		}

		res = INF;
		rep(i, m)
		{
			res = min(res, cnt[i][0]);
			res = min(res, cnt[i][n - 1]);
		}
		rep(i, n)
		{
			res = min(res, cnt[0][i]);
			res = min(res, cnt[m - 1][i]);
		}
		printf("%d\n", res);
	}
	return 0;
}