#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

using namespace std;

const int INF = 1000000;
const int N = 102;

int h, w;
char mapData[N][N];
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
int height[N][N];

class State{
public:
  int y, x, cost;
};

int bfs(){
  State u, v;
  u.y = 0;
  u.x = 0;
  u.cost = 0;
  queue<State> Q;
  Q.push(u);
  int res = INF;
  fill(height[0], height[N], INF);
  height[0][0] = 0;
  while(!Q.empty()){
    u = Q.front(); Q.pop();
    if(mapData[u.y][u.x] == '&') res = min(res, u.cost);
    for(int i=0;i<4;i++){
      v.y = u.y + dy[i];
      v.x = u.x + dx[i];
      if(v.y < 0 || v.y >= h) continue;
      if(v.x < 0 || v.x >= w) continue;
      v.cost = u.cost;
      if(mapData[v.y][v.x] != '#' && mapData[u.y][u.x] == '#') ++v.cost;
      if(height[v.y][v.x] <= v.cost) continue;
      height[v.y][v.x] = v.cost;
      Q.push(v);
    }
  }
  return res;
}

int main(){
  while(cin >> w >> h && (h || w)){
    for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++){
	cin >> mapData[i][j];
      }
    }
    h += 2;
    w += 2;
    for(int i=0;i<h;i++) mapData[i][0] = '.';
    for(int i=0;i<h;i++) mapData[i][w-1] = '.';
    for(int j=0;j<w;j++) mapData[0][j] = '.';
    for(int j=0;j<w;j++) mapData[h-1][j] = '.';
    cout << bfs() << endl;
  }
  return 0;
}