#include<iostream>
#include <utility>

using namespace std;

int INF = 1 << 28;
int n;
int m;
char map[100][100];
int visited[100][100];
int dx[] = { 0, 1, 0, -1 };
int dy[] = { 1, 0, -1, 0 };
int ans;

void solve(pair<int,int> pos, int c) {

	int x = pos.first;
	int y = pos.second;
	if (x < 0 || y < 0 || x >= n || y >= m) {
		ans = c;
		return;
	}
	if (visited[y][x] <= c)
		return;
	visited[y][x] = c;
	if (ans <= c) {
		return;
	}
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i];
		int ny = y + dy[i];
			solve(make_pair(nx, ny), c + ((map[y][x] == '#') ? 1 : 0));
	}
}

int main(){
	while (1) {
		ans = INF;
		cin>>n;
		cin>>m;
		if ((n | m) == 0)
			break;
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				cin >> map[i][j];
				visited[i][j] = INF;
			}
		}
		if (n <= 2 || m <= 2) {
			cout << 0 <<"\n";
			continue;
		}
		int sx = 0;
		int sy = 0;
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				if (map[i][j] == '&') {
					sx = j;
					sy = i;
					i = INF;
					break;
				}
			}
		}
		solve(make_pair(sx,sy), 0);
		cout <<ans<<"\n";
	}
}