x,y=map(int,input().split()) if x==0 and y==0: print(0) else: r=1 if x==0 or y==0 else 2 if (x+y)%2!=0: b=float('inf') elif abs(x)==abs(y): b=1 else: b=2 print(min(r,b))