#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
int d[110][110];
bool isOutOfRange(int x, int y, int w, int h) {
  if (x < 0 || x >= w || y < 0 || y >= h) return true;
  return false;
}
string s[110];
int main() {
  int x, y;
  int sx, sy;
  while (cin >> x >> y && x && y) {
    for (int i = (0); i < (int)(y); i++) cin >> s[i];
    for (int i = (0); i < (int)(y); i++)
      for (int j = (0); j < (int)(x); j++) {
        if (s[i][j] == '&') {
          sx = j;
          sy = i;
        }
        d[i][j] = INF;
      }
    priority_queue<pair<int, pair<int, int> > > q;
    q.push(make_pair(0, make_pair(sy, sx)));
    d[sy][sx] = 0;
    pair<int, pair<int, int> > p;
    int ans = INF;
    while (!q.empty()) {
      p = q.top();
      q.pop();
      for (int i = (0); i < (int)(4); i++) {
        int nx = p.second.second + dx[i];
        int ny = p.second.first + dy[i];
        if (isOutOfRange(nx, ny, x, y)) {
          ans = min(ans, -p.first);
          break;
        }
        int c = -p.first + (s[ny][nx] == '#' ? 1 : 0);
        if (d[ny][nx] <= c) continue;
        d[ny][nx] = c;
        q.push(make_pair(-c, make_pair(ny, nx)));
      }
      if (ans != INF) break;
    }
    cout << ans << endl;
  }
}
