#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int N, M;
string line;
vector<string> field;

const int MAX_V = 11000;
const int INF = 1000000009;
int V;
struct edge { int to, cap, cost, rev; };
vector<edge> G[MAX_V];
int dist[MAX_V];
int prevv[MAX_V];
int preve[MAX_V];

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

void add_edge(int from, int to, int cap, int cost) {
	edge e1 = { to, cap, cost, G[to].size() };
	edge e2 = { from, 0, -cost, G[from].size() };
	G[from].push_back(e1);
	G[to].push_back(e2);
}

void bellman_ford(int s) {
	fill(dist, dist+V, INF);
	dist[s] = 0;
	bool update = true;
	while(update) {
		update = false;
		rep(v,V) {
			if(dist[v] == INF) continue;
			rep(i,G[v].size()) {
				edge& e = G[v][i];
				if(e.cap > 0 && dist[e.to] > dist[v] + e.cost) {
					dist[e.to] = dist[v] + e.cost;
					prevv[e.to] = v;
					preve[e.to] = i;
					update = true;
				}
			}
		}
	}
}

int min_cost_flow(int s, int t, int f) {
	int res = 0;
	while(f > 0) {
		bellman_ford(s);
		if(dist[t] == INF) return -1;

		int d = f;
		for(int v=t; v!=s; v=prevv[v]) {
			d = min(d, G[prevv[v]][preve[v]].cap);
		}

		res += d * dist[t];
		f -= d;
		for(int v=t; v!=s; v=prevv[v]) {
			edge& e = G[prevv[v]][preve[v]];
			e.cap -= d;
			G[v][e.rev].cap += d;
		}
	}
	return res;
}

void solve() {
	V = N * M + 2;
	int s = V - 2;
	int t = V - 1;
	rep(v,V) G[v].clear();

	rep(y,M) {
		rep(x,N) {
			if(field[y][x] == '&') {
				add_edge(y*N+x, t, 1, 0);
			}
			rep(k,4) {
				int xx = x + dx[k];
				int yy = y + dy[k];
				if(xx >= 0 && yy >= 0 && xx < N && yy < M) {
					if(field[y][x] == '.' && field[yy][xx] == '#') {
						add_edge(y*N+x, yy*N+xx, 1, 1);
					} else {
						add_edge(y*N+x, yy*N+xx, 1, 0);
					}
				}
			}
		}
	}

	rep(y,M) {
		if(field[y][0] == '#') {
			add_edge(s, y*N+0, 1, 1); 
		} else {
			add_edge(s, y*N+0, 1, 0); 
		}

		if(field[y][N-1] == '#') {
			add_edge(s, y*N+N-1, 1, 1); 
		} else {
			add_edge(s, y*N+N-1, 1, 0); 			
		}
	}

	repa(x,1,N-2) {
		if(field[0][x] == '#') {
			add_edge(s, 0*N+x, 1, 1);
		} else {
			add_edge(s, 0*N+x, 1, 0);
		}

		if(field[M-1][x] == '#') {
			add_edge(s, (M-1)*N+x, 1, 1);
		} else {
			add_edge(s, (M-1)*N+x, 1, 0);			
		}
	}
	
	int res = min_cost_flow(s, t, 1);
	cout << res << endl;
}

int main() {
	while(scanf("%d%d", &N, &M), N|M) {
		field.clear();
		rep(i,M) {
			cin >> line;
			field.push_back(line);
		}
		solve();
	}
}