a,b = map(int,input().split()) print(min(a,b)*2 if min(a,b)*2<(a+b)//2 else (a+b)%2)