#include <bits/stdc++.h>
using namespace std;
char mas[105][105];
int w, h, d[] = {0, 1, 0, -1};
int used[105][105];
int bfs() {
  int ans = (1 << 30);
  queue<pair<int, pair<int, int> > > que;
  fill_n(used[0], 105 * 105, (1 << 30));
  que.push(pair<int, pair<int, int> >(0, pair<int, int>(0, 0)));
  used[0][0] = 0;
  while (!que.empty()) {
    pair<int, pair<int, int> > p = que.front();
    que.pop();
    if (mas[p.second.first][p.second.second] == '&') {
      ans = min(ans, p.first);
      continue;
    }
    for (int i = (0); i < (4); ++i) {
      int nx = p.second.first + d[i], ny = p.second.second + d[3 - i],
          pt = p.first;
      if (!(nx >= 0 && nx < h + 2 && ny >= 0 && ny < w + 2)) continue;
      if (mas[nx][ny] == '#') pt++;
      if (used[nx][ny] > pt) {
        que.push(pair<int, pair<int, int> >(pt, pair<int, int>(nx, ny)));
        used[nx][ny] = pt;
      }
    }
  }
  return ans;
}
int main() {
  for (int i = (0); i < (102); ++i) mas[0][i] = '.';
  while (cin >> w >> h, w) {
    for (int i = (1); i < (h + 1); ++i) {
      mas[i][0] = mas[i][w + 1] = '.';
      for (int j = (1); j < (w + 1); ++j) cin >> mas[i][j];
    }
    for (int i = (0); i < (w + 2); ++i) mas[h + 1][i] = '.';
    cout << bfs() << endl;
  }
}
