#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
char Map[101][101];
int cost[105][105];
int bfs(pair<int, int> sp, int m, int n) {
  const int dir[][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
  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, sp));
  while (!que.empty()) {
    pair<int, pair<int, int> > curr = que.top();
    que.pop();
    int c = curr.first;
    int cr = curr.second.first, cc = curr.second.second;
    if (cr == 0 || cr == m + 1 || cc == 0 || cc == n + 1) return c;
    if (cost[cr][cc] > c)
      cost[cr][cc] = c;
    else
      continue;
    for (int k = 0; k < (4); k++) {
      int nr = cr + dir[k][0], nc = cc + dir[k][1];
      if (Map[cr][cc] == '.' && Map[nr][nc] == '#') {
        que.push(pair<int, pair<int, int> >(c + 1, pair<int, int>(nr, nc)));
      } else {
        que.push(pair<int, pair<int, int> >(c, pair<int, int>(nr, nc)));
      }
    }
  }
  return -1;
}
int main() {
  int n, m;
  while (cin >> n >> m && n && m) {
    memset(Map, 0, sizeof(Map));
    for (int i = 0; i < (m + 2); i++)
      for (int j = 0; j < (n + 2); j++) cost[i][j] = INF;
    pair<int, int> sp;
    for (int i = 0; i < (m); i++) {
      for (int j = 0; j < (n); j++) {
        cin >> Map[i][j];
      }
    }
    for (int i = 0; i < (m); i++) {
      for (int j = 0; j < (n); j++) {
        if (Map[i][j] == '&') {
          sp.first = i, sp.second = j;
        }
      }
    }
    int res = bfs(sp, m, n);
    cout << res << endl;
  }
  return 0;
}
