#include <bits/stdc++.h>
using namespace std;
char str[102][102];
int bfs[102][102];
int v[102][102];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main() {
  int a, b;
  while (scanf("%d%d", &a, &b), a + b) {
    for (int i = 0; i < 102; i++)
      for (int j = 0; j < 102; j++) str[i][j] = '.';
    for (int i = 0; i < b; i++) {
      scanf("%s", str[i] + 1);
    }
    for (int i = 0; i < 102; i++)
      for (int j = 0; j < 102; j++) {
        bfs[i][j] = -1;
        v[i][j] = 0;
      }
    bfs[0][0] = 0;
    deque<pair<int, int> > Q;
    Q.push_back(make_pair(0, 0));
    while (Q.size()) {
      int row = Q.front().first;
      int col = Q.front().second;
      Q.pop_front();
      if (v[row][col]) continue;
      v[row][col] = 1;
      for (int i = 0; i < 4; i++) {
        if (0 <= row + dx[i] && row + dx[i] < 102 && 0 <= col + dy[i] &&
            col + dy[i] < 102) {
          if ((!~bfs[row + dx[i]][col + dy[i]]) ||
              (bfs[row + dx[i]][col + dy[i]] >
               bfs[row][col] +
                   (str[row + dx[i]][col + dy[i]] == '#' ? 1 : 0))) {
            bfs[row + dx[i]][col + dy[i]] =
                bfs[row][col] + (str[row + dx[i]][col + dy[i]] == '#' ? 1 : 0);
            if (str[row + dx[i]][col + dy[i]] == '#') {
              Q.push_back(make_pair(row + dx[i], col + dy[i]));
            } else
              Q.push_front(make_pair(row + dx[i], col + dy[i]));
          }
        }
      }
    }
    for (int i = 0; i < 102; i++) {
      for (int j = 0; j < 102; j++) {
        if (str[i][j] == '&') printf("%d\n", bfs[i][j]);
      }
    }
  }
}
