#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int dis[110][110],p[110][110];
typedef pair<int,pair<int,int> >P;
priority_queue<P,vector<P>,greater<P> >Q;
void Qpush(int a,int b,int c){Q.push(make_pair(a,make_pair(b,c)));}
int main(){
  int h,w;
  while(cin>>w>>h&&h+w){
    lol(i,h)lol(j,w){
      char z;cin>>z;
      if(z=='&')Qpush(0,i,j);
      if(z=='#')p[i][j]=1;
      else p[i][j]=0;
      dis[i][j]=mod;
    }
    while(!Q.empty()){
      int cost=Q.top().first;
      int y=Q.top().second.first;
      int x=Q.top().second.second;
      Q.pop();
      if(dis[y][x]<=cost)continue;
      dis[y][x]=cost;
      int dx[]={-1,0,1,0},dy[]={0,1,0,-1};
      lol(i,4){
	int xx=x+dx[i],yy=y+dy[i];
	if(xx<0||xx==w||yy<0||yy==h)continue;
	if(dis[yy][xx]>cost+p[yy][xx])Qpush(cost+p[yy][xx],yy,xx);
      }
    }
    int ans=mod;
    for(int i=0;i<h;i++)ans=min(ans,min(dis[i][0],dis[i][w-1]));
    for(int j=0;j<w;j++)ans=min(ans,min(dis[0][j],dis[h-1][j]));
    cout<<ans<<endl;
  }
  return 0;
}