#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
using namespace std;
typedef pair<int,int> Pt;
typedef pair<int,Pt> P;
#define fr first
#define sc second
#define INF (1 << 26)
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
Pt st;
char mas[105][105];
int w,h,d[]={0,1,0,-1};
bool used[105][105];
int bfs(){
  priority_queue< P , vector<P> , greater<P> > que;
  fill_n(used[0],105*105,false);
  que.push(P(0,st));
  used[st.fr][st.sc] = true;
  while(!que.empty()){
    P p = que.top(); que.pop();
    rep(i,4){
      int nx = p.sc.fr + d[i] , ny = p.sc.sc + d[3-i] , pt = p.fr;
      if(nx < 0 || ny < 0 || nx >= h || ny >= w) return pt;
      if(used[nx][ny]) continue;
      if(mas[p.sc.fr][p.sc.sc] == '.' && mas[nx][ny] == '#') pt++;
      que.push(P(pt,Pt(nx,ny)));
      used[nx][ny] = true;
    }
  }
}
int main(){
  while(cin >> w >> h , w){
    rep(i,h) rep(j,w){
      cin >> mas[i][j];
      if(mas[i][j] == '&') st = Pt(i,j) , mas[i][j] = '.';
    }
    cout << bfs() << endl;
  }
}