#include<iostream>
#include <utility>
 
using namespace std;
 
int INF = 1 << 28;
int n;
int m;
char map[100][100];
int visited[100][100];
int dx[] = { 0, 1, 0, -1 };
int dy[] = { 1, 0, -1, 0 };
int ans;
 
void solve(pair<int,int> pos, int c) {
 
    int x = pos.first;
    int y = pos.second;
    
    if (visited[y][x] <= c)
        return;
    visited[y][x] = c;
    if (ans <= c) {
        return;
    }
    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i];
        int ny = y + dy[i];
		if (nx < 0 || ny < 0 || nx >= n || ny >= m) {
        ans = c;
        return;
    }
            solve(make_pair(nx, ny), c + ((map[y][x] != '#' && map[ny][nx] == '#') ? 1 : 0));
    }
}
 
int main(){
    while (1) {
        ans = INF;
        cin>>n;
        cin>>m;
        if ((n | m) == 0)
            break;
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                cin >> map[i][j];
                visited[i][j] = INF;
            }
        }
        int sx = 0;
        int sy = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (map[i][j] == '&') {
                    sx = j;
                    sy = i;
                    i = INF;
                    break;
                }
            }
        }
        solve(make_pair(sx,sy), 0);
 
        cout <<ans<<"\n";
    }
}