x, n = map(int, input().split()) if x < 0: f = 1 x *= -1 else: f = 0 def is_ok(arg): S = arg * (arg + 1) // 2 return S <= abs(x) def bs(ok, ng): while abs(ok - ng) > 1: mid = (ok + ng) // 2 if is_ok(mid): ok = mid else: ng = mid return ok m = bs(0, 10**9 * 2) if n <= m: S = n * (n+1) // 2 x += (-1) * S x *= (-1) ** f print(x) exit() S = m * (m+1) // 2 x += (-1) * S x *= (-1) ** f n -= m if x <= 0: if n % 2 == 0: x -= n // 2 else: x += m - (-n//2) else: if n % 2 == 0: x += n // 2 else: x -= m - (-n//2) print(x)