#include <bits/stdc++.h>
using namespace std;
const int INF = 10000;
const int MAX = 100;
const int dx[] = {0, -1, 0, 1};
const int dy[] = {-1, 0, 1, 0};
int m, n, sx, sy;
int step[MAX + 2][MAX + 2];
char field[MAX + 2][MAX + 2];
int main() {
  while (cin >> n >> m && m) {
    memset(step, -1, sizeof(step));
    memset(field, '.', sizeof(field));
    for (int i = 1; i <= m; i++) {
      for (int j = 1; j <= n; j++) {
        cin >> field[i][j];
        if (field[i][j] == '&') {
          sx = j;
          sy = i;
        }
      }
    }
    priority_queue<pair<int, pair<int, int> >,
                   vector<pair<int, pair<int, int> > >,
                   greater<pair<int, pair<int, int> > > >
        que;
    que.push(pair<int, pair<int, int> >(0, pair<int, int>(sx, sy)));
    while (!que.empty()) {
      pair<int, pair<int, int> > s = que.top();
      que.pop();
      int x = s.second.first, y = s.second.second, z = s.first;
      if (step[y][x] >= 0) continue;
      step[y][x] = z;
      for (int i = 0; i < 4; i++) {
        int nx = x + dx[i], ny = y + dy[i], nz = z;
        if (field[ny][nx] == '#') nz++;
        if (nx >= 0 && nx <= n + 1 && ny >= 0 && ny <= m + 1) {
          que.push(pair<int, pair<int, int> >(nz, pair<int, int>(nx, ny)));
        }
      }
    }
    int res = INF;
    for (int i = 0; i <= m + 1; i++)
      for (int j = 0; j <= n + 1; j++)
        if (i == 0 || i == m + 1 || j == 0 || j == n + 1)
          res = min(res, step[i][j]);
    cout << res << endl;
  }
}
