#include <bits/stdc++.h>
using namespace std;
int INF = 1 << 28;
int n;
int m;
char map[100][100];
int visited[100][100];
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int ans;
int solve(pair<int, int> pos, int c) {
  int x = pos.first;
  int y = pos.second;
  if (x < 0 || y < 0 || x >= n || y >= m) {
    return ans = c;
  }
  if (visited[y][x] <= c) return INF;
  visited[y][x] = c;
  if (ans < c) {
    return INF;
  }
  int res = INF;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    res = min(res, solve(make_pair(nx, ny), c + ((map[y][x] == '#') ? 1 : 0)));
  }
  return res;
}
int main() {
  while (1) {
    ans = INF;
    cin >> n;
    cin >> m;
    if ((n | m) == 0) break;
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < n; j++) {
        cin >> map[i][j];
        visited[i][j] = INF;
      }
    }
    if (n <= 2 || m <= 2) {
      cout << 0 << "\n";
      continue;
    }
    int sx = 0;
    int sy = 0;
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < n; j++) {
        if (map[i][j] == '&') {
          sx = j;
          sy = i;
          i = INF;
          break;
        }
      }
    }
    cout << solve(make_pair(sx, sy), 0) << "\n";
  }
}
