#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int x,y;
cin>>x>>y;
int res = 0;
int falg = 1;
for(int d = 1;;d *= 2){
if((falg == -1 && x - d <= y && y <= x) || (y >= x && falg == 1 && x + d >= y)){
res += abs(y - x);
break;
}else{
falg *= -1;
res += d*2;
}
}
cout<<res;
return 0;
}