#include <iostream>
#include <memory>
#include <memory.h>
#include <cmath>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
#define USE_MATH_DEFINES
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

int memo[110][110];
char field[110][110];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};
int n, m;

int main(){
	while(cin >> n >> m && (n || m)){
		fill(&memo[0][0], &memo[109][109] + 1, INF);
		fill(&field[0][0], &field[109][109] + 1, '.');
		rep(i, m)rep(j, n) cin >> field[j+1][i+1];
		memo[0][0] = 0;
		priority_queue<PP, vector<PP>, greater<PP> > que;
		que.push(PP(0, P(0, 0)));
		while(!que.empty()){
			
			PP pp = que.top();
			que.pop();
			int c = pp.first;
			int x = pp.second.first;
			int y = pp.second.second;
			if(c > memo[x][y]) continue;
			if(field[x][y] == '&') {
				cout << c << endl;
				break;
			}
			rep(i, 4){
				int x2 = x + dx[i];
				int y2 = y + dy[i];
				if(0 <= x2 && x2 <= n + 1 && 0 <= y2 && y2 <= m + 1){
					int cost = 0;
					if(field[x][y] == '.' && field[x2][y2] == '#') cost = 1;
					if(memo[x2][y2] > memo[x][y]+ cost){
						memo[x2][y2] = memo[x][y] + cost;
				
						que.push(PP(memo[x2][y2], P(x2, y2)));
					}
				}
			}
		}
	}
	return 0;
}