#include <bits/stdc++.h>
using namespace std;
int H, W;
char grid[101][101];
int const dx[4] = {-1, 1, 0, 0};
int const dy[4] = {0, 0, -1, 1};
int memo[101][101];
inline bool IN(int x, int y) { return 0 <= x && x < W && 0 <= y && y < H; }
int const INF = 1 << 29;
int main() {
  while (cin >> W >> H && W) {
    int sx, sy;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        cin >> grid[i][j];
        if (grid[i][j] == '&') {
          sx = j, sy = i;
        }
      }
    }
    memset(memo, -1, sizeof(memo));
    int ans = 1 << 29;
    priority_queue<pair<int, pair<int, int> > > Q;
    Q.push(pair<int, pair<int, int> >(0, pair<int, int>(sx, sy)));
    while (!Q.empty()) {
      pair<int, pair<int, int> > piii = Q.top();
      Q.pop();
      int const x = piii.second.first;
      int const y = piii.second.second;
      int const cost = piii.first;
      for (int k = 0; k < 4; k++) {
        int nx = x + dx[k], ny = y + dy[k];
        if (IN(nx, ny)) {
          int ncost = cost + (grid[ny][nx] == '#');
          if (memo[ny][nx] == -1 || memo[ny][nx] > ncost) {
            memo[ny][nx] = ncost;
            Q.push(pair<int, pair<int, int> >(ncost, pair<int, int>(nx, ny)));
          }
        } else {
          ans = min(ans, cost);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
