#include <bits/stdc++.h>
using namespace std;
struct Point {
  int x;
  int y;
  Point(int x_, int y_) : x(x_), y(y_) {}
};
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main(void) {
  while (1) {
    int w, h;
    int field[105][105] = {};
    int costfield[105][105];
    Point gPoint(0, 0);
    cin >> w >> h;
    for (int i = 0; i < 105; ++i) {
      for (int j = 0; j < 105; ++j) {
        costfield[i][j] = INT_MAX;
        if (i == 0 || j == 0 || i == h + 3 || j == w + 3) costfield[i][j] = -1;
      }
    }
    if (w == 0 && h == 0) return 0;
    for (int y = 1; y <= h + 2; ++y) {
      for (int x = 1; x <= w + 2; ++x) {
        if (x == 1 || y == 1 || x == w + 2 || y == h + 2) {
          field[y][x] = '.';
        } else {
          scanf(" %c", &field[y][x]);
          if (field[y][x] == '&') gPoint = Point(x, y);
        }
      }
    }
    costfield[1][1] = 0;
    queue<Point> que;
    que.push(Point(1, 1));
    while (!que.empty()) {
      Point now = que.front();
      que.pop();
      for (int i = 0; i < 4; ++i) {
        Point next(now.x + dx[i], now.y + dy[i]);
        int c =
            costfield[now.y][now.x] +
            (field[now.y][now.x] == '.' && field[next.y][next.x] == '#' ? 1
                                                                        : 0);
        if (c < costfield[next.y][next.x]) {
          costfield[next.y][next.x] = c;
          que.push(next);
        }
      }
    }
    cout << costfield[gPoint.y][gPoint.x] << endl;
  }
  return 0;
}
