#include <bits/stdc++.h>
using namespace std;
const int INF = 1e+8;
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};
void debug(const vector<string>& m) {
  cout << "[debug]" << endl;
  for (int y = 0; y < m.size(); y++) cout << m[y] << endl;
}
int w, h;
pair<int, int> search_goal(vector<string>& m) {
  int gx, gy;
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      if (m[y][x] == '&') {
        m[y][x] = '.';
        gx = x;
        gy = y;
        break;
      }
    }
  }
  return pair<int, int>(gx, gy);
}
int solve(vector<string>& m) {
  int n = w * h;
  int d[110][110];
  bool used[110][110];
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      d[y][x] = INF;
      used[y][x] = false;
    }
  }
  pair<int, int> gp = search_goal(m);
  int gx = gp.first;
  int gy = gp.second;
  priority_queue<pair<int, pair<int, int> >,
                 vector<pair<int, pair<int, int> > >,
                 greater<pair<int, pair<int, int> > > >
      q;
  q.push(pair<int, pair<int, int> >(0, pair<int, int>(0, 0)));
  d[0][0] = 0;
  int result = INF;
  while (!q.empty()) {
    int cost = q.top().first;
    int x = q.top().second.first;
    int y = q.top().second.second;
    q.pop();
    used[y][x] = true;
    if (x == gx && y == gy) {
      result = min(result, cost);
    }
    for (int i = 0; i < 4; i++) {
      int mx = x + dx[i];
      int my = y + dy[i];
      if (mx < 0 || my < 0 || mx >= w || my >= h || used[my][mx]) continue;
      int next_cost = cost;
      if (m[my][mx] == '#') {
        next_cost++;
      }
      if (next_cost < d[my][mx]) {
        d[my][mx] = next_cost;
        pair<int, pair<int, int> > next(next_cost, pair<int, int>(mx, my));
        q.push(next);
      }
    }
  }
  return result;
}
int main() {
  while (cin >> w >> h, w || h) {
    vector<string> m(h + 2);
    string t;
    for (int i = 0; i < w + 2; i++) {
      t.push_back('.');
    }
    m[0] = m[h + 1] = t;
    for (int y = 1; y <= h; y++) {
      string s, s_;
      cin >> s;
      s_ = "." + s + ".";
      m[y] = s_;
    }
    w += 2;
    h += 2;
    cout << solve(m) << endl;
  }
}
