#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<climits>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<double>vd;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
typedef pair<int,pii>piii;
#define rrep(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) rrep(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define maxs(a,b) (a)=max(a,b)
#define mins(a,b) (a)=min(a,b)
///#include<sstream>
///#include<cstring>
///#include<stack>
///#include<complex>

int W,H;
char fld[100][101];
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
int solve(){
    bool done[100][100]={{0}};
    priority_queue<piii,vector<piii>,greater<piii> >Q;
    rep(i,H){
        Q.push(piii(0,pii(i,0)));
        Q.push(piii(0,pii(i,W-1)));
    }
    rep(j,W){
        Q.push(piii(0,pii(0,j)));
        Q.push(piii(0,pii(H-1,j)));
    }

    while(!Q.empty()){
        piii p=Q.top();Q.pop();
        if(done[p.se.fi][p.se.se])continue;
        done[p.se.fi][p.se.se]=true;
        if(fld[p.se.fi][p.se.se]=='&')return p.fi;

        rep(i,4){
            int ty=p.se.fi+dy[i],tx=p.se.se+dx[i];
            if(ty<0||ty>=H||tx<0||tx>=W)continue;
            int tcost=p.fi;
            if(fld[p.se.fi][p.se.se]=='#'&&fld[ty][tx]!='#')tcost++;
            Q.push(piii(tcost,pii(ty,tx)));
        }
    }
}

int main(){
    while(scanf("%d%d",&W,&H),W||H){
        rep(i,H)scanf("%s",fld[i]);
        printf("%d\n",solve());
    }
    return 0;
}