#include
#include
using namespace std;
int main()
{
int x;
int y;
int z=0;
int i = 0;
cin >> x >> y;
while (x % 2 == 0 && y % 2 == 0)
{
x = x / 2;
y = y / 2;
i++;
}
while (x % 2 == 0 && y % 2 != 0)
{
x = x / 2;
}
while (x % 2 != 0 && x % 2 == 0)
{
y = y / 2;
}
while (z != x || z != y)
{
z = abs(x - y);
}
cout << z * pow(2, i);
return 0;
}