#include <bits/stdc++.h>
using namespace std;
struct St {
  int x, y, c;
  St(int cst, pair<int, int> p) : c(cst), y(p.first), x(p.second) {}
  bool operator>(const St &s) const { return c > s.c; }
};
const int inf = 999999;
int xdir[4] = {0, -1, 0, 1}, ydir[4] = {1, 0, -1, 0};
int bfs(char a[101][101], int w, int h, pair<int, int> p) {
  int r = -1, vis[101][101];
  priority_queue<St, vector<St>, greater<St>> que;
  fill(&vis[0][0], &vis[h][w], inf);
  vis[p.first][p.second] = 0;
  que.push(St(0, p));
  while (!que.empty()) {
    St s = que.top();
    que.pop();
    if (s.x < 0 || s.x >= w || s.y < 0 || s.y >= h) {
      r = s.c;
      break;
    }
    for (int i = 0; i < 4; i++) {
      int dy = s.y + ydir[i], dx = s.x + xdir[i];
      if (dy < 0 || dy >= h || dx < 0 || dx >= w) {
        St t = (a[s.y][s.x] == '#') ? St((s.c + 1), pair<int, int>(dy, dx))
                                    : St(s.c, pair<int, int>(dy, dx));
        que.push(t);
      } else if (vis[dy][dx] > s.c) {
        int u = inf;
        if (a[s.y][s.x] == '#' && a[dy][dx] == '.') {
          u = s.c + 1;
        } else {
          u = s.c;
        }
        if (u < vis[dy][dx]) {
          vis[dy][dx] = u;
          que.push(St(u, pair<int, int>(dy, dx)));
        }
      }
    }
  }
  return r;
}
int main() {
  int w, h;
  char a[101][101];
  pair<int, int> p;
  while (cin >> w >> h && (w + h)) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        cin >> a[i][j];
        if (a[i][j] == '&') {
          p = pair<int, int>(i, j);
          a[i][j] = '.';
        }
      }
    }
    cout << bfs(a, w, h, p) << endl;
  }
  return 0;
}
