#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int INF = 1e9;

int W, H, my[] = {0, 0, 1, -1}, mx[] = {1, -1, 0, 0};
vector< vector<char> > v;

int solve(){
  priority_queue<PP, vector<PP>, greater<PP> > open;
  open.push(PP(0, P(0, 0)));
  vector< vector<int> > closed(H, vector<int>(W, INF));
  while(!open.empty()){
    PP tmp = open.top(); open.pop();
    int y = tmp.second.first, x = tmp.second.second, cnt = tmp.first;
    if(closed[y][x] <= cnt) continue;
    closed[y][x] = cnt;
    REP(i, 4){
      int ny = y + my[i], nx = x + mx[i];
      if(ny >= 0 && nx >= 0 && ny < H && nx < W) open.push(PP((v[y][x] == '#' && v[ny][nx] != '#' ? cnt + 1 : cnt), P(ny, nx)));
    }
  }
  P tar;
  REP(i, H) REP(j, W) if(v[i][j] == '&') tar = P(i, j);
  return closed[tar.first][tar.second];
}

int main() {
  while(cin >>W >>H && W){
    H += 2; W += 2;
    v = vector< vector<char> >(H, vector<char>(W, '.'));
    FOR(i, 1, H - 1) FOR(j, 1, W - 1) cin >>v[i][j];
    cout <<solve() <<endl;
  }
  return 0;
}