x,n=map(int,input().split()) l,r=0,10**10 while r-l>1: c=(l+r)//2 if x>0: if x-c*(c+1)//2>0: l=c else: r=c else: if x+c*(c+1)//2>0: r=c else: l=c if x<=0: l+=1 print(l) if n<=l: stc=n*(n+1)//2 if x>0: print(x-stc) else: print(x+stc) else: stc=l*(l+1)//2 if x>0: now=x-stc else: now=x+stc zan=n-l if zan%2==0: print(now+zan//2) else: print(now-l-1-(zan-1)//2)