#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, long long int> > edge[101010];
bool visit[101010];
long long int dijkstra(long long int from, long long int to) {
  for (long long int i = 0; i < ((long long int)(101010)); i++)
    visit[i] = false;
  priority_queue<pair<long long int, long long int> > q;
  q.push({0, from});
  while (!q.empty()) {
    pair<long long int, long long int> now = q.top();
    long long int now_v = now.second;
    long long int now_c = now.first;
    if (now_v == to) return -now_c;
    q.pop();
    if (visit[now_v]) continue;
    visit[now_v] = true;
    for (long long int i = 0;
         i < ((long long int)(((long long int)(edge[now_v]).size()))); i++) {
      long long int next = edge[now_v][i].first;
      long long int w = edge[now_v][i].second;
      if (!visit[next]) q.push({now_c - w, next});
    }
  }
  return -1;
}
string ss[111];
long long int w, h;
inline string dots(long long int x) {
  string res = "";
  for (long long int i = 0; i < ((long long int)(x)); i++) res += ".";
  return res;
}
inline long long int coord(long long int y, long long int x) {
  return y * (w + 2) + x;
}
int main(int argc, char *argv[]) {
  while (1) {
    cin >> w >> h;
    if (max(w, h) <= 0) break;
    ss[0] = ss[h + 1] = dots(w + 2);
    string s;
    for (long long int i = 0; i < ((long long int)(h)); i++) {
      cin >> s;
      ss[i + 1] = "." + s + ".";
    }
    for (long long int i = 0; i < ((long long int)(101010)); i++)
      edge[i].clear();
    long long int goal = -1;
    for (long long int i = 0; i < ((long long int)(h + 2)); i++) {
      for (long long int j = 0; j < ((long long int)(w + 2)); j++) {
        if (ss[i][j] == '&') goal = coord(i, j);
        if (j - 1 >= 0)
          edge[coord(i, j)].push_back(
              {coord(i, j - 1), ss[i][j - 1] == '#' ? 1 : 0});
        if (j + 1 < w + 2)
          edge[coord(i, j)].push_back(
              {coord(i, j + 1), ss[i][j + 1] == '#' ? 1 : 0});
        if (i - 1 >= 0)
          edge[coord(i, j)].push_back(
              {coord(i - 1, j), ss[i - 1][j] == '#' ? 1 : 0});
        if (i + 1 < h + 2)
          edge[coord(i, j)].push_back(
              {coord(i + 1, j), ss[i + 1][j] == '#' ? 1 : 0});
      }
    }
    cout << dijkstra(0, goal) << endl;
  }
  return 0;
}
