#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
typedef pair<int,int> Pt;
typedef pair<int,Pt> P;
#define fr first
#define sc second
#define INF (1 << 30)
#define FOR(i,b,n) for(int i = (b) ; i < (n) ; ++i )
#define rep(i,n) FOR(i,0,n)
char mas[105][105];
int w,h,d[]={0,1,0,-1};
int used[105][105];
int bfs(){
  int ans = INF;
  queue<P> que;
  fill_n(used[0],105*105,INF);
  que.push(P(0,Pt(0,0)));
  used[0][0] = 0;
  while(!que.empty()){
    P p = que.front(); que.pop();
    if(mas[p.sc.fr][p.sc.sc] == '&'){
      ans = min(ans,p.fr);
      continue;
    }
    rep(i,4){
      int nx = p.sc.fr + d[i] , ny = p.sc.sc + d[3-i] , pt = p.fr;
      if(!(nx>=0&&nx<h+2&&ny>=0&&ny<w+2)) continue;
      if(mas[nx][ny] == '#') pt++;
      if(used[nx][ny] > pt){
        que.push(P(pt,Pt(nx,ny)));
        used[nx][ny] = pt;
      }
    }
  }
  return ans;
}
int main(){
  rep(i,102) mas[0][i] = '.';
  while(cin >> w >> h , w){
    FOR(i,1,h+1){
      mas[i][0] = mas[i][w+1] = '.';
      FOR(j,1,w+1) cin >> mas[i][j];
    }
    rep(i,w+2) mas[h+1][i] = '.';
    cout << bfs() << endl;
  }
}