x,n=map(int,input().split()) mode=0 if x<=0: mode=1 x=-x if x==0: lb=0 else: ub=n+1 lb=0 while ub-lb>1: t=(ub+lb)//2 if x-t*(t+1)//2>0: lb=t else: ub=t x=x-lb*(lb+1)//2 left=n-lb if left%2==0: x+=left//2 else: x+=left//2 x-=n if mode: x=-x print(x)