#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int INF = 1 << 30;
int dy[] = {-1, 0, 0, 1};
int dx[] = {0, -1, 1, 0};
int n, m;
string c[110];

void solve() {
  c[0] = c[m + 1] = string(n + 2, '.');
  for (int i = 1; i <= m; i++) {
    cin >> c[i];
    c[i] = "." + c[i] + ".";
  }
  n += 2, m += 2;
  int dis[110][110];
  fill_n((int*)dis, 110 * 110, INF);
  dis[0][0] = 0;
  deque<pii> deq = {{0, 0}};
  while (!deq.empty()) {
    int y, x;
    tie(y, x) = deq.front(); deq.pop_front();
    if (c[y][x] == '&') {
      cout << dis[y][x] << endl;
      return;
    }
    for (int i = 0; i < 4; i++) {
      int ny = y + dy[i], nx = x + dx[i];
      if (ny >= 0 && ny < m && nx >= 0 && nx < n) {
        int cost = (c[y][x] == '.' && c[ny][nx] == '#');
        if (dis[ny][nx] > dis[y][x] + cost) {
          dis[ny][nx] = dis[y][x] + cost;
          if (cost) deq.emplace_back(ny, nx);
          else deq.emplace_front(ny, nx);
        }
      }
    }
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  while (cin >> n >> m, n) {
    solve();
  }  

  return 0;
}
