#include<bits/stdc++.h>
#define int long long
using namespace std;
int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
int X,Y;
map<int,int> mp;
int Dfs(int x)
{
	if(x<=X) return X-x;
	if(mp[x]) return mp[x];
	int ans=x-X;
	if(x&1) ans=min(ans,Dfs(x-1)+1),ans=min(ans,Dfs(x+1)+1);
	else ans=min(ans,Dfs(x/2)+1);
	return mp[x]=ans;
}
signed main()
{
	X=read(),Y=read();
	cout<<Dfs(Y)<<endl;
	return 0;
}
#include<bits/stdc++.h>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
int rd(){
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9') {
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f*x;
}

int main(){
	vector<int> v={6,10,12,15,18,20,24,30};
	int n;cin>> n;
	if(n==3) cout<<6<<" "<<10<<" "<<15<<'\n';
	else rep(i,1,n)cout<<v[(i-1)%v.size()]+(i-1)/v.size()*30<<" ";
	return 0;
}



