#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

const int dir[][2] = {
	1, 0,
	0, 1,
	-1, 0,
	0, -1
};

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );

	while ( true )
	{
		int w, h;
		cin >> w >> h;

		if ( !( w | h ) )
		{
			break;
		}

		VS board( h );

		EACH( line, board )
		{
			cin >> line;
		}

		int sy, sx;

		REP( i, 0, h )
		{
			REP( j, 0, w )
			{
				if ( board[i][j] == '&' )
				{
					sy = i;
					sx = j;
				}
			}
		}

		VVI cost( h, VI( w, INT_MAX ) );
		cost[ sy ][ sx ] = 0;

		queue< PII > que;
		que.push( MP( sy, sx ) );

		while ( !que.empty() )
		{
			auto cur = que.front();
			que.pop();

			REP( d, 0, 4 )
			{
				auto next = cur;

				next.fst += dir[d][0];
				next.snd += dir[d][1];

				if ( !( 0 <= next.fst && next.fst < h && 0 <= next.snd && next.snd < w ) )
				{
					continue;
				}

				int nextcost = cost[ cur.fst ][ cur.snd ] + ( board[ cur.fst ][ cur.snd ] == '.' && board[ next.fst ][ next.snd ] == '#' );

				if ( cost[ next.fst ][ next.snd ] <= nextcost )
				{
					continue;
				}

				cost[ next.fst ][ next.snd ] = nextcost;
	
				que.push( next );
			}
		}

		int res = INT_MAX;

		REP( i, 0, w )
		{
			res = min( res, min( cost[0][i], cost[ h - 1 ][i] ) );
		}

		REP( i, 0, h )
		{
			res = min( res, min( cost[i][0], cost[i][ w - 1 ] ) );
		}

		cout << res << endl;
	}

	return 0;
}