#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<climits>
using namespace std;

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

int N, M;

struct Data{
	int y, x, cost;
	Data(){}
	Data(int _y, int _x, int _cost){
		y = _y; x = _x; cost = _cost;
	}
};

bool IsOutside(int y, int x){
	return y < 0 || N <= y || x < 0 || M <= x;
}

int main(){
	while(cin >> N >> M, N || M){
		swap(N, M);
		
		char fld[100][100];
		queue<Data> q;
		Data q_front;
		int cost[100][100];
		fill_n( (int*)cost, 100*100, INT_MAX );

		for(int i = 0; i < N; i++){
			for(int j = 0; j < M; j++){
				cin >> fld[i][j];
				if(fld[i][j] == '&') q.push( Data(i, j, 0) );
			}
		}

		int ans = INT_MAX;
		while( !q.empty() ){
			q_front = q.front(); q.pop();
			if(cost[q_front.y][q_front.x] <= q_front.cost) continue;
			cost[q_front.y][q_front.x] = q_front.cost;

			for(int i = 0; i < 4; i++){
				int ny = q_front.y + dy[i], nx = q_front.x + dx[i];
				
				if( IsOutside(ny, nx) ){
					ans = min(ans, q_front.cost);
				}
				else{
					int cnt = 0;
					if(fld[q_front.y][q_front.x] != '#' && fld[ny][nx] == '#')
						cnt = 1;
					q.push( Data(ny, nx, q_front.cost + cnt) );
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}