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