#include <bits/stdc++.h>
using namespace std;
int n, m;
int gx, gy;
int INF = 10000000;
char fie[120][120];
int jp[120][120];
int dx[5] = {1, 0, -1, 0, 0};
int dy[5] = {0, 1, 0, -1, 0};
void bfs() {
  queue<pair<pair<int, int>, int> > que;
  for (int i = 0; i <= m + 1; i++) {
    for (int j = 0; j <= n + 1; j++) {
      jp[j][i] = INF;
    }
  }
  que.push(pair<pair<int, int>, int>(pair<int, int>(0, 0), 0));
  jp[0][0] = 0;
  while (que.size()) {
    pair<pair<int, int>, int> p = que.front();
    que.pop();
    for (int i = 0; i <= 4; i++) {
      int kx = p.first.first + dx[i], ky = p.first.second + dy[i], k = p.second;
      if (kx >= 0 && kx <= n + 1 && ky >= 0 && ky <= m + 1) {
        if (fie[kx][ky] == '.' && k < jp[kx][ky]) {
          que.push(pair<pair<int, int>, int>(pair<int, int>(kx, ky), k));
          jp[kx][ky] = k;
        }
        if (fie[kx][ky] == '&' && k < jp[kx][ky]) {
          que.push(pair<pair<int, int>, int>(pair<int, int>(kx, ky), k));
          jp[kx][ky] = k;
        }
        if (fie[kx][ky] == '#' && k + 1 < jp[kx][ky]) {
          que.push(pair<pair<int, int>, int>(pair<int, int>(kx, ky), k + 1));
          jp[kx][ky] = k + 1;
        }
      }
    }
  }
}
int main(void) {
  while (1) {
    scanf("%d%d", &n, &m);
    if (n == 0 && m == 0) break;
    memset(fie, '.', sizeof(fie));
    for (int i = 1; i <= m; i++) {
      for (int j = 1; j <= n; j++) {
        cin >> fie[j][i];
        if (fie[j][i] == '&') gx = j, gy = i;
      }
    }
    bfs();
    printf("%d\n", jp[gx][gy]);
  }
  return 0;
}
