a = int(input())
b = int(input())
a1=b1=c1=c2=0
c=0
# x={1:c+=1,2:c+=2,3:c+=3}

while(a!=b):
    #  print ("@")
    if a<b:
        
        if a1==0:
            a+=1
            if c1==0:
                c+=1
                c1+=1
            elif c1==1:
                c+=2
                c1+=1
            elif c1==2:
                c+=3
                c1=0
            a1=1
            b1=0
        elif(b1==0):
            b-=1
            if c2==0:
                c+=1
                c2+=1
            elif c2==1:
                c+=2
                c2+=1
            elif c2==2:
                c+=3
                c2=0
            a1=0
            b1=1
    elif a>b:
        
        if a1==0:
            b+=1
            # print("#")
            if c1==0:
                c+=1
                c1+=1
            elif c1==1:
                c+=2
                c1+=1
            elif c1==2:
                c+=3
                c1=0
            a1=1
            b1=0
        elif(b1==0):
            # print("##")
            a-=1
            if c2==0:
                c+=1
                c2+=1
            elif c2==1:
                c+=2
                c2+=1
            elif c2==2:
                c+=3
                c2=0
            b1=1
            a1=0
print(c)