import sys input = sys.stdin.readline def calc(sx,sy): if sy>=70: haba=10**20 else: haba=min(1<sy: ANS+=ty-sy sy=ty elif sy>ty: ANS+=sy-ty ty=sy haba,left,right=calc(sx,sy) haba2,left2,right2=calc(tx,ty) if left>left2: sx,sy,tx,ty=tx,ty,sx,sy plus=1<<63 for i in range(10**9): haba,left,right=calc(sx,sy+i) haba2,left2,right2=calc(tx,ty) plus=min(plus,i*2+(left2-left)//haba) if left<=left2<=right: break print(ANS+plus)