#include<iostream>
#include<string>

#define N 102

using namespace std;

int n,m;
int omap[N][N];
int map[N][N];

void dfs(int i, int j){
	const int ci[] = {-1,0,1,0};
	const int cj[] = {0,1,0,-1};
	
	if( i < 0 || i > m+2 || j < 0 || j > n+2 )
		return ;
	if( map[i][j] == 1 )
		return ;
	
	map[i][j] = 1;
	for(int k = 0; k < sizeof(ci)/sizeof(*ci); ++k){
		dfs( i+ci[k], j+cj[k] );
	}
	return ;
}
void printMap(){
	for(int i=0; i<m+2;++i){
		for(int j=0;j<n+2;++j){
			cout << map[i][j];
		}
		cout << endl;
	}
	cout << endl;
}


int main(){
	while(true){
		int si, sj;
		int ans = 1000;
		int tans = 0;
		
		cin>>n>>m;
		if(m==0&&n==0)break;
		
		for(int i = 0; i < N; ++i){
			for(int j = 0; j < N; ++j){
				omap[i][j] = map[i][j] = 0;
			}
		}
		
		for(int i = 1; i < m+1; ++i){
			string s;
			cin>>s;
			for(int j = 1; j < n+1; ++j){
				if( s[j-1] == '.' ){
					omap[i][j] = map[i][j] = 0;
				}else if( s[j-1] == '&'){
					si = i;
					sj = j;
					omap[i][j] = map[i][j] = 0;
				}else if( s[j-1] == '#' ){
					omap[i][j] = map[i][j] = 1;
				}
			}
		}
		
		for(int i = si; i >= 0; --i){ if( map[i][sj] == 0 ){ dfs( i, sj ); ++tans; } }
		for(int i = 0; i < N; ++i )for(int j = 0; j < N; ++j) map[i][j] = omap[i][j];
		ans = min(ans,tans);
		for(int i = si; i <= m+1; ++i){ if( map[i][sj] == 0 ){ dfs( i, sj ); ++tans; } }
		for(int i = 0; i < N; ++i )for(int j = 0; j < N; ++j) map[i][j] = omap[i][j];
		ans = min(ans,tans);
		for(int j = sj; j >= 0; --j){ if( map[si][j] == 0 ){ dfs( si, j ); ++tans; } }
		for(int i = 0; i < N; ++i )for(int j = 0; j < N; ++j) map[i][j] = omap[i][j];
		ans = min(ans,tans);
		for(int j = sj; j <= n+1; ++j){ if( map[si][j] == 0 ){ dfs( si, j ); ++tans; } }
		for(int i = 0; i < N; ++i )for(int j = 0; j < N; ++j) map[i][j] = omap[i][j];
		ans = min(ans,tans);

		cout << ans-1 << endl;
	}
	return 0;
}