#include <bits/stdc++.h>

using namespace std;

char MapData[100][100];
int Cost[100][100];
queue<pair<int, int> > QueueData;


void solve(int totalRow, int totalCol) {
	int curtRow, curtCol, cost;
	int dx[] = { 1,0,-1,0 };
	int dy[] = { 0,1,0,-1 };

	//cout << QueueData.front().first << " " << QueueData.front().second << endl;
	while (!QueueData.empty()) {
		pair<int, int> current = QueueData.front();
		QueueData.pop();
		for (int j = 0; j < 4; j++) {
			curtRow = current.first + dy[j];
			curtCol = current.second + dx[j];
			if (curtRow<0 || curtRow>totalRow - 1 || curtCol<0 || curtCol>totalCol - 1) {
				continue;
			}
			cost = Cost[current.first][current.second];
			if (MapData[curtRow][curtCol] == '#' && MapData[current.first][current.second] == '.') {
				++cost;
			}
			if (cost >= Cost[curtRow][curtCol]) {
				continue;
			}
			Cost[curtRow][curtCol] = cost;
			QueueData.push(make_pair(curtRow, curtCol));
		}
	}
}

int main() {
	int m, n, cnt;

	while (cin >> n >> m, n) {
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				cin >> MapData[i][j];
				Cost[i][j] = 10000000;
				if (MapData[i][j] == '&') {
					MapData[i][j] = '.';
					Cost[i][j] = 0;
					QueueData.push(make_pair(i, j));
				}
			}
		}
		solve(m, n);
		cnt = 10000000;
		for (int i = 0; i < m; i++) {
			cnt = min(cnt, Cost[i][0]);
			cnt = min(cnt, Cost[i][n - 1]);
		}
		for (int i = 0; i < n; i++) {
			cnt = min(cnt, Cost[0][i]);
			cnt = min(cnt, Cost[m - 1][i]);
		}
		cout << cnt << endl;
	}

	return 0;
}

