#include <bits/stdc++.h>
using namespace std;
void solve(vector<string>& field, int i, int j, vector<vector<int> >& cost) {
  int h = field.size(), w = field[0].size();
  int di[] = {-1, 1, 0, 0};
  int dj[] = {0, 0, -1, 1};
  for (int k = int(0); k < int(4); k++) {
    int ni = i + di[k], nj = j + dj[k];
    if (ni < 0 || h <= ni || nj < 0 || w <= nj) continue;
    if (field[ni][nj] == field[i][j] && cost[ni][nj] > cost[i][j]) {
      cost[ni][nj] = cost[i][j];
      solve(field, ni, nj, cost);
    }
  }
  for (int k = int(0); k < int(4); k++) {
    int ni = i + di[k], nj = j + dj[k];
    if (ni < 0 || h <= ni || nj < 0 || w <= nj) continue;
    if (field[i][j] == '.' && field[ni][nj] == '#' &&
        cost[ni][nj] > cost[i][j]) {
      cost[ni][nj] = cost[i][j];
      solve(field, ni, nj, cost);
    }
  }
  for (int k = int(0); k < int(4); k++) {
    int ni = i + di[k], nj = j + dj[k];
    if (ni < 0 || h <= ni || nj < 0 || w <= nj) continue;
    if (field[i][j] == '#' && field[ni][nj] == '.' &&
        cost[ni][nj] > cost[i][j]) {
      cost[ni][nj] = cost[i][j] + 1;
      solve(field, ni, nj, cost);
    }
  }
}
int main() {
  for (int w, h; cin >> w >> h, w | h;) {
    vector<string> field(h + 2);
    field[0] = field[h + 1] = string(w + 2, '.');
    for (int i = int(0); i < int(h); i++) {
      cin >> field[i + 1];
      field[i + 1] = '.' + field[i + 1] + '.';
    }
    pair<int, int> p;
    for (int i = int(0); i < int(field.size()); i++)
      for (int j = int(0); j < int(field[0].size()); j++)
        if (field[i][j] == '&') {
          p = make_pair(i, j);
          field[i][j] = '.';
        }
    vector<vector<int> > cost(field.size(),
                              vector<int>(field[0].size(), 1 << 29));
    cost[0][0] = 0;
    solve(field, 0, 0, cost);
    cout << cost[p.first][p.second] << endl;
  }
  return 0;
}
