#include <bits/stdc++.h>
using namespace std;
int main() {
  int dx[] = {0, 1, 0, -1};
  int dy[] = {-1, 0, 1, 0};
  int n, m;
  while (cin >> n >> m, n || m) {
    char ba[n][m];
    pair<int, int> castle;
    for (int y = 0; y < (int)m; ++y) {
      for (int x = 0; x < (int)n; ++x) {
        cin >> ba[x][y];
        if (ba[x][y] == '&') castle = pair<int, int>(x, y);
      }
    }
    int dp[n][m];
    for (int x = 0; x < (int)n; ++x) {
      for (int y = 0; y < (int)m; ++y) {
        if (x == 0 || x == n - 1 || y == 0 || y == m - 1)
          dp[x][y] = (ba[x][y] == '#') ? 1 : 0;
        else
          dp[x][y] = 1 << 30;
      }
    }
    bool update = true;
    while (update) {
      update = false;
      for (int x = 1; x < n - 1; ++x) {
        for (int y = 1; y < m - 1; ++y) {
          for (int k = 0; k < (int)4; ++k) {
            int xx = x + dx[k], yy = y + dy[k];
            if (ba[x][y] == '#') {
              if (dp[x][y] > dp[xx][yy] + 1) {
                dp[x][y] = dp[xx][yy] + 1;
                update = true;
              }
            } else {
              if (dp[x][y] > dp[xx][yy]) {
                dp[x][y] = dp[xx][yy];
                update = true;
              }
            }
          }
        }
      }
    }
    cout << dp[castle.first][castle.second] << endl;
  }
}
