#include <bits/stdc++.h>
const double Eps = 1e-4;
using namespace std;
int n, m;
char g[100][100];
int d[100][100];
const int Inf = 10000000;
int cost(int x, int y) { return g[y][x] == '#' ? 1 : 0; }
int main() {
  while (scanf("%d %d\n", &n, &m), n | m) {
    for (int i = 0; i < m; ++i) {
      char buf[128];
      cin.getline(buf, sizeof(buf));
      for (int j = 0; j < n; ++j) g[i][j] = buf[j];
    }
    for (int i = 0; i < m; ++i)
      for (int j = 0; j < n; ++j)
        d[i][j] = i == 0 || j == 0 || i == m - 1 || j == n - 1 ? 0 : Inf;
    for (bool changed = true; changed;) {
      changed = false;
      int ori[100][100];
      memcpy(ori, d, sizeof(ori));
      for (int y = 0; y < m; ++y)
        for (int x = 1; x < n; ++x)
          d[y][x] = min(d[y][x], d[y][x - 1] + cost(x - 1, y));
      for (int y = 0; y < m; ++y)
        for (int x = n - 2; x >= 0; --x)
          d[y][x] = min(d[y][x], d[y][x + 1] + cost(x + 1, y));
      for (int x = 0; x < n; ++x)
        for (int y = 1; y < m; ++y)
          d[y][x] = min(d[y][x], d[y - 1][x] + cost(x, y - 1));
      for (int x = 0; x < n; ++x)
        for (int y = m - 2; y >= 0; --y)
          d[y][x] = min(d[y][x], d[y + 1][x] + cost(x, y + 1));
      for (int i = 0; i < m; ++i)
        for (int j = 0; j < n; ++j)
          if (d[i][j] != ori[i][j]) changed = true;
    }
    int destY, destX;
    for (destY = 0; destY < m; ++destY)
      for (destX = 0; destX < n; ++destX)
        if (g[destY][destX] == '&') goto EndLoop;
  EndLoop:
    printf("%d\n", d[destY][destX]);
  }
  return 0;
}
