#include <iostream>
#include <string>
#include <utility>
#include <functional>
#include <algorithm>
#include <vector>
#include <queue>

const int INF = 1e9 + 10;

using namespace std;

struct Point {
  int y, x, cost;
  bool f;
  Point() = default;
  Point(int y, int x, int c, bool f): y(y), x(x), cost(c), f(f) { }
};

int main() {
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n + m == 0) {
      break;
    }

    vector<string> c(m);
    for (int i = 0; i < m; i++) {
      cin >> c[i];
    }

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

    for (int i = 0; i < m; i++) {
      for (int j = 0; j < n; j++) {
        if (c[i][j] == '&') {
          s.y = i;
          s.x = j;
          s.cost = 0;
        }
      }
    }

    queue<Point> que;
    que.push(s);

    int ans = INF;

    vector<vector<int>> checked(m);
    for (int i = 0; i < m; i++) {
      checked[i] = vector<int>(n, INF);
    }

    while (!que.empty()) {
      if (ans == 0) {
        break;
      }
      Point p = que.front(); que.pop();
      if (checked[p.y][p.x] <= p.cost) {
        continue;
      }
      checked[p.y][p.x] = p.cost;
      for (int i = 0; i < 4; i++) {
        int ny = p.y + dy[i];
        int nx = p.x + dx[i];
        if (ny < 0 || ny >= m) {
          ans = min(ans, p.cost);
          continue;
        }
        if (nx < 0 || nx >= n) {
          ans = min(ans, p.cost);
          continue;
        }
        int cost = 0;
        bool f = false;
        if (!p.f) {
          if (c[ny][nx] == '#') {
            f = true;
            cost = 1;
          } else {
            f = false;
          }
        }
        

        que.push(Point(ny, nx, p.cost + cost, f));
      }
    }

    cout << ans << endl;


  }

  return 0;
}