#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> S;
const int INF = 10000;
const int MAX = 100;
const int dx[] = {0, -1, 0, 1};
const int dy[] = {-1, 0, 1, 0};
int m,n,sx,sy;
int step[MAX + 2][MAX + 2];
char field[MAX + 2][MAX + 2];

int main()
{
    while(cin >> n >> m && m) {
        memset(step, -1, sizeof(step));
        memset(field, '.', sizeof(field));
        
        for(int i = 1; i <= m; i++) {
            for(int j = 1; j <= n; j++) {
                cin >> field[i][j];
                if(field[i][j] == '&') {
                    sx = j;
                    sy = i;
                }
            }
        }

        priority_queue<S, vector<S>, greater<S> > que;
        que.push(S(0, P(sx, sy)));
        while(!que.empty()) {
            S s = que.top(); que.pop();
            int x = s.second.first, y = s.second.second, z = s.first;
            if(step[y][x] >= 0) continue;
            step[y][x] = z;

            for(int i = 0; i < 4; i++) {
                int nx = x + dx[i], ny = y + dy[i], nz = z;
                if(field[ny][nx] == '#' && field[y][x] != '#') nz++;
                if(nx >= 0 && nx <= n + 1 && ny >= 0 && ny <= m + 1) {
                    que.push(S(nz, P(nx, ny)));
                }
            }
        }

        int res = INF;
        for(int i = 0; i <= m + 1; i++)
            for(int j = 0; j <= n + 1; j++)
                if(i == 0 || i == m + 1 || j == 0 || j == n + 1) 
                    res = min(res, step[i][j]);

        cout << res << endl;
    }
}