#include <iostream>
using namespace std;

int x,y;
char field[100][100];//field[y][x]
int flag;

void DFS(int a,int b){
	if(field[b][a] == '&'){
		flag = 1;
	}
	else
		field[b][a] = '-';
		
	if((field[b+1][a] == '.'|| field[b+1][a] == '&') && b+1 < y )
		DFS(a,b+1);
	if((field[b-1][a] == '.'|| field[b-1][a] == '&') && b-1 >= 0 )
		DFS(a,b-1);	
	if((field[b][a+1] == '.'|| field[b][a+1] == '&')&& a+1 < x )
		DFS(a+1,b);	
	if((field[b][a-1] == '.'|| field[b][a-1] == '&')&& a-1 >= 0 )
		DFS(a-1,b);
}

void hey(int a,int b){
	field[b][a] = '-';
	for(int i=-1;i<=1;i++){
		for(int j=-1;j<=1;j++){
			if(field[b+i][a+j]=='#' && b+i >= 0 && b+i < y && a+j >= 0 && a+j < x)
				hey(a+j,b+i);
		}
	}
}

int main(){
	while(cin >> x >> y){
		if(!x && !y)
			break;
		for(int i=0;i<y;i++){
			for(int j=0;j<x;j++){
				cin >> field[i][j];
			}
		}
		for(int i=0;i<x;i++){
			if(field[0][i] == '.')
				field[0][i] = '-';
			if(field[y-1][i] == '.')
				field[y-1][i] = '-';
		}
		for(int i=0;i<y;i++){
			if(field[i][0] == '.')
				field[i][0] = '-';
			if(field[i][x-1] == '.')
				field[i][x-1] = '-';
		}


		int count = 0;
		flag = 0;
		for(int i=0;i<y;i++){
			for(int j=0;j<x;j++){
				if(field[i][j] == '-')
					DFS(j,i);
			}
		}	
		while(!flag){
			int a,b;
			for(int i=0;i<y;i++){
				for(int j=0;j<x;j++){
					if(field[i][j] == '#'){
						a = j;b = i;
						goto next;
					}
				}
			}
			next:;
			hey(a,b);
			count++;
			flag = 0;
			for(int i=0;i<y;i++){
				for(int j=0;j<x;j++){
					if(field[i][j] == '-')
						DFS(j,i);
				}
			}
		}
		cout << count << endl;
	}
	return 0;
} 