#include <bits/stdc++.h>
using namespace std;
typedef pair<int, pair<int, int> > PP;
int M, N, mv[5] = {-1, 0, 1, 0, -1}, res;
char A[105][105], B[105][105];
int d[105][105];
priority_queue<PP> Q;
int main() {
  for (; scanf("%d%d\n", &N, &M), N + M;) {
    res = 100000000;
    memset(d, 0x7f, sizeof(d));
    for (int i = 0; i <= M + 1; i++)
      for (int j = 0; j <= N + 1; j++) B[i][j] = '.';
    for (int i = 0; i < M; i++) gets(B[i + 1] + 1);
    for (int i = 0; i <= M + 1; i++) {
      B[i][N + 1] = '.';
      B[i][N + 2] = 0;
    }
    N++;
    M++;
    Q.push(make_pair(0, make_pair(0, 0)));
    while (!Q.empty()) {
      PP tmp = Q.top();
      Q.pop();
      int y = tmp.second.first;
      int x = tmp.second.second;
      int cost = tmp.first;
      if (d[y][x] <= cost) continue;
      if (B[y][x] == '&') {
        res = min(res, cost);
        continue;
      }
      d[y][x] = cost;
      for (int i = 0; i < 4; i++) {
        int ny = y + mv[i];
        int nx = x + mv[i + 1];
        if (ny < 0 || ny > M || nx < 0 || nx > N) continue;
        int nc = cost + (B[y][x] == '#' && B[ny][nx] != '#');
        if (nc < d[ny][nx]) {
          Q.push(make_pair(nc, make_pair(ny, nx)));
        }
      }
    }
    printf("%d\n", res);
  }
}
