include[HTML_REMOVED]
using namespace std;
struct node{
int x;
int step;
};
const int maxn=200000;
bool flag[maxn];
void BFS(int n,int k){
queue[HTML_REMOVED] t;
memset(flag,false,sizeof(flag));
node Node;
Node.x=n;Node.step=0;
flag[n]=true;
t.push(Node);
while(!t.empty()){
node top=t.front();
t.pop();
if(top.x==k){
cout<[HTML_REMOVED]=0)
{ node temp1;
int Newx=top.x-1;
flag[Newx]=true;
temp1.x=Newx;
temp1.step=top.step+1;
t.push(temp1);
}
if(!flag[top.x+1]&&top.x+1<=2k)
{ node temp2;
int Newx=top.x+1;
flag[Newx]=true;
temp2.x=Newx;
temp2.step=top.step+1;
t.push(temp2);
}
if(!flag[top.x2]&&top.x2<=2k)
{ node temp3;
int Newx=top.x*2;
flag[Newx]=true;
temp3.x=Newx;
temp3.step=top.step+1;
t.push(temp3);
}
}
}
int main(){
int n,k;
cin>>n>>k;
BFS(n,k);
return 0;
}