#include <bits/stdc++.h>
using std::sort;
int n, m, ans;
int main() {
  scanf("%d%d", &n, &m);
  while (n < m) {
    if ((m & 1) == 0) {
      m >>= 1;
      ++ans;
    } else {
      ++m;
      ++ans;
    }
  }
  ans += n - m;
  printf("%d\n", ans);
  return 0;
}
