Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at some point the number stops being positive, the device breaks down. The display can show arbitrarily large numbers. Initially, the display shows number *n*.

Bob wants to get number *m* on the display. What minimum number of clicks he has to make in order to achieve this result?
The first and the only line of the input contains two distinct integers *n* and *m* (1 ≤ *n*, *m* ≤ 10<sup class="upper-index">4</sup>), separated by a space .
/*وَقُلِ اعْمَلُوا فَسَيَرَى اللَّهُ عَمَلَكُمْ*/


/*
  **** writen by: Abdelrahman mahmoud Eltohamy *****
 ****    day   : 29 aug 2023 ****
 ** شبين القناطر ****

*/
#include<bits/stdc++.h>
#include<vector>
#include<deque>
#include<utility>
#include<map>
 
using namespace std ;
 
#define ll long long 
#define en endl 
#define yes cout<<"YES"<<en
#define no cout<<"NO"<<en
#define neg1   cout<<-1<<endl 
#define Abdelrahman_Mahmoud_Eltohamy ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define case int TT; cin>>TT; while (TT--)
#define all(v) v.begin(), v.end()
#define pq priority_queue
#define rall(v) v.rbegin(), v.rend()
#define ull unsigned long long
#define PI 3.1415926535897932384626433832795l
#define gr greater<int>
#define endstr string::npos
#define imax INT_MAX
const long long MOD = 1e9 + 7, inf = 1e18;
ll oo = 0x3f3f3f3f3f3f3f3f;
const ll NN = 1'000'000'000'000L;
// const ll sz = 2e5 + 5;
#define Num_of_Digits(n) ((int)log10(n) + 1)
#define isON(n,k) ( (n)>>(k)&1)


 // direction array
// int dx[] = { 0, 0, 1, -1, 1, 1, -1, -1 };
// int dy[] = { -1, 1, 0, 0, -1, 1, 1, -1 };


int dx[4] = {1,-1,0,0} ;
int dy [4] = {0,0,1,-1} ;

// bitmasks
/*
Number of leading zeroes: __builtin_clz(x)
Number of trailing zeroes : __builtin_ctz(x)
Number of 1-bits: __builtin_popcount(x)
last one : __lg()
 */


ll n  ,m,p,h,l,r ,c,q,z ,a,b,d ; 
const ll N = 2e5+12;// 4e5 +1


// vector<bool>stak;
//  bool iscyclic,issymitric ;
//  bool isB ;
  
   /*adjacant list*/
// vector<vector<int>>adj;
// vector<bool>vis;
// vector<int>level ;
// int maxlevel  ;


// vector<int>col; 

  /*frq map*/ 
// map<int,vector<int>>v ;
// map<int,int>vis ;


vector<vector<pair<int,int>>>adj (20100);
vector<int>parant(20100) ;

ll dijkstra(ll start, ll target)
{
    vector<ll>dis(20100,oo) ;
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>q; 
    dis[start] =0; 
    q.push({0,start}) ;
    while (!q.empty())
    {
        ll node = q.top().second ;
        ll cost = q.top().first; 
        q.pop() ;
        if (cost!= dis[node])
            continue;
          if (node ==  target)
          {
            return dis[target] ;
          }
        for (auto i:adj[node])
        {
            int to=  i.second ;
            int toc= i.first ;
            if (dis[to]>dis[node] + toc)
            {
                dis[to] = dis[node] + toc ;
                q.push({dis[to],to}) ;
                parant[to] =node; 
            }
        }
  }
  return -1; 
  
}




int main()
{
    Abdelrahman_Mahmoud_Eltohamy ;
    for (int i =1 ;i<10020 ;i++)
    {
      adj[i].push_back({1,i-1}) ;
      adj[i].push_back({1  , i*2}) ;
      parant[i] =i; 
    }
    cin>>n>>m; 
    cout<<dijkstra(n,m) ;
    


 
}