#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int dy[] = {-1, 1, 0, 0};
    int dx[] = {0, 0, 1, -1};

    for(;;){
        int w, h;
        cin >> w >> h;
        if(w == 0)
            return 0;

        vector<string> s(h+2);
        s[0] = s[h+1] = string(w+2, ' ');
        int y0, x0;
        for(int i=1; i<=h; ++i){
            cin >> s[i];
            s[i] = ' ' + s[i] + ' ';
            int j = s[i].find('&');
            if(j != string::npos){
                y0 = i;
                x0 = j;
            }
        }

        vector<vector<int> > check(h+2, vector<int>(w+2, INT_MAX));
        check[y0][x0] = 0;
        multimap<int, pair<int, int> > mm;
        mm.insert(make_pair(0, make_pair(y0, x0)));
        for(;;){
            int cost = mm.begin()->first;
            int y = mm.begin()->second.first;
            int x = mm.begin()->second.second;
            mm.erase(mm.begin());

            if(s[y][x] == ' '){
                cout << cost << endl;
                break;
            }

            for(int i=0; i<4; ++i){
                int y1 = y + dy[i];
                int x1 = x + dx[i];
                int c = cost;
                if(s[y][x] == '.' && s[y1][x1] == '#')
                    ++ c;
                if(c < check[y1][x1]){
                    mm.insert(make_pair(c, make_pair(y1, x1)));
                    check[y1][x1] = c;
                }
            }
        }
    }
}