#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-4;

using namespace std;

int n, m;
char g[100][100];
int dx[] = { 0, 1, 0, -1 };
int dy[] = { -1, 0, 1, 0 };

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

int main()
{
	while (scanf("%d %d\n", &n, &m), n | m)
	{
		for (int i = 0; i < m; ++i)
		{
			char buf[128];
			cin.getline(buf, sizeof(buf));
			for (int j = 0; j < n; ++j)
				g[i][j] = buf[j];
		}

		int destY, destX;
		for (int i = 0; i < m; ++i)
		{
			for (int j = 0; j < n; ++j)
			{
				if (g[i][j] == '&')
				{
					destY = i;
					destX = j;
					g[i][j] = '.';
				}
			}
		}
		bool visited[100][100];
		memset(visited, 0, sizeof(visited));
		priority_queue<P, vector<P>, greater<P> > q;
		q.push(P(0, Q(destX, destY)));
		visited[destY][destX] = true;
		int ans = -1;
		while (ans == -1)
		{
			P v = q.top();
			q.pop();
			int x = v.second.first;
			int y = v.second.second;
			for (int i = 0; i < 4; ++i)
			{
				int nx = x + dx[i];
				int ny = y + dy[i];
				if (nx < 0 || ny < 0 || nx >= n || ny >= m)
				{
					ans = v.first;
					break;
				}
				if (visited[ny][nx])
					continue;
				int c = v.first;
				if (g[y][x] == '.' && g[ny][nx] == '#')
					++c;
				q.push(P(c, Q(nx, ny)));
				visited[ny][nx] = true;
			}
		}
		printf("%d\n", ans);
	}

	return 0;
}