#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

typedef pair<int,int> P;

int main() {
  int dx[] = {0,1,0,-1};
  int dy[] = {-1,0,1,0};
  
  int n,m;
  while(cin >> n >> m,n||m) {
    char ba[n][m];
    P castle;
    REP(y,m) {
      REP(x,n) {
        cin >> ba[x][y];
        if (ba[x][y] == '&')
          castle = P(x,y);
      }
    }
    int dp[n][m];
    REP(x,n) {
      REP(y,m) {
        if (x == 0 || x == n-1 || y == 0 || y == m-1)
          dp[x][y] = 0;
        else
          dp[x][y] = INF;
      }
    }
    bool update = true;
    while(update) {
      update = false;
      for (int x=1; x<n-1; ++x) {
        for (int y=1; y<m-1; ++y) {
          REP(k,4) {
            int xx = x+dx[k], yy = y+dy[k];
            if (ba[x][y] != '#' && ba[xx][yy] == '#') {
              if (dp[x][y] > dp[xx][yy] + 1) {
                dp[x][y] = dp[xx][yy] + 1;
                update = true;
              }
            } else {
              if (dp[x][y] > dp[xx][yy]) {
                dp[x][y] = dp[xx][yy];
                update = true;
              }
            }
          }
        }
      }
    }
    cout << dp[castle.first][castle.second] << endl;
  }
}