#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

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

int main() {
	int n, m;
	while(cin >> n >> m, n) {
		vs field(m);
		pii s;
		REP(i, m) {
			cin >> field[i];
			REP(j, n) {
				if(field[i][j] == '&') {
					s.first = i;
					s.second = j;
				}
			}
		}

		queue<pii> Q;
		Q.push(s);
		vvi cost(m, vi(n, INF));
		cost[s.first][s.second] = 0;
		int ans = INF;
		while(!Q.empty()) {
			pii p = Q.front();
			Q.pop();
			int sy = p.first;
			int sx = p.second;
			int sc = cost[sy][sx];

			REP(d, 4) {
				int ny = sy + dy[d];
				int nx = sx + dx[d];
				int nc = sc;
				if(nx < 0 || n <= nx || ny < 0 || m <= ny) {
					ans = min(ans, sc);
					continue;
				}
				if(field[ny][nx] == '#') {
					nc++;
				}
				if(nc < cost[ny][nx]) {
					cost[ny][nx] = nc;
					Q.push(make_pair(ny, nx));
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}