#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
struct NODE {
  int x, y;
  int count;
  char sw;
};
bool operator<(const NODE &a, const NODE &b) { return a.count > b.count; }
int w, h;
bool isWrong(const NODE &n) {
  if (n.x >= w || n.y >= h) return true;
  if (n.x < 0 || n.y < 0) return true;
  return false;
}
bool edge(const NODE &n) {
  if (n.x == 0 || n.x == w - 1) return true;
  if (n.y == 0 || n.y == h - 1) return true;
  return false;
}
int main() {
  string s;
  while (cin >> w >> h, w) {
    vector<string> map(h);
    NODE t;
    t.count = 0, t.sw = '.';
    for (int i = 0; i < h; i++) {
      cin >> map[i];
      if (~map[i].find("&")) t.x = map[i].find("&"), t.y = i;
    }
    int memo[100][100];
    for (int i = 0; i < 100; i++)
      for (int j = 0; j < 100; j++) memo[i][j] = (1 << 21);
    priority_queue<NODE> Q;
    Q.push(t);
    while (Q.size()) {
      NODE q = Q.top();
      Q.pop();
      if (memo[q.y][q.x] <= q.count) continue;
      if (edge(q) && q.sw == '.') {
        cout << q.count << endl;
        break;
      }
      memo[q.y][q.x] = q.count;
      for (int i = 0; i < 4; i++) {
        NODE nt;
        nt.x = q.x + dx[i], nt.y = q.y + dy[i], nt.count = q.count;
        if (isWrong(nt)) continue;
        if (q.sw == '#' && map[nt.y][nt.x] == '.') nt.count++;
        nt.sw = map[nt.y][nt.x];
        Q.push(nt);
      }
    }
  }
}
