#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

const int dx[] = {1, -1, 0,  0};
const int dy[] = {0,  0, 1, -1};
char field[104][104];

int main() {
    int n, m;
    while (cin >> n >> m, n) {
        for (int i=0; i<104; ++i) {
            for (int j=0; j<104; ++j) {
                if (i % 103 == 0 || j % 103 == 0) {
                    field[i][j] = '*';
                } else {
                    field[i][j] = '.';
                }
            }
        }
        for (int i=2; i<=m+1; ++i) {
            for (int j=2; j<=n+1; ++j) {
                cin >> field[i][j];
            }
        }
        bool ok = false;
        int k = 0;
        for (; !ok; ++k) {
            queue<pair<int,int> > q;
            q.push(make_pair(1,1));
            while ( ! q.empty() && ! ok) {
                int x = q.front().first;
                int y = q.front().second;
                q.pop();
                for (int i=0; i<4; ++i) {
                    if (field[y + dy[i]][x + dx[i]] == '&') {
                        ok = true;
                        break;
                    }
                    if (field[y + dy[i]][x + dx[i]] == '.') {
                        field[y + dy[i]][x + dx[i]] = '#';
                        q.push(make_pair(x + dx[i], y + dy[i]));
                    }
                }
            }
            if (ok) break;
            queue<pair<int,int> > q2;
            q2.push(make_pair(1,1));
            while ( ! q2.empty()) {
                int x = q2.front().first;
                int y = q2.front().second;
                q2.pop();
                for (int i=0; i<4; ++i) {
                    if (field[y + dy[i]][x + dx[i]] == '#') {
                        field[y + dy[i]][x + dx[i]] = '.';
                        q2.push(make_pair(x + dx[i], y + dy[i]));
                    }
                }
            }
        }
        cout << k << endl;
    }
    return 0;
}