import sys

def input(): return sys.stdin.readline().rstrip("\r\n")
def List(): return list(map(int, input().split()))
def Num(): return int(input())


x, k, d = List()
x = abs(x)
if d * k > x:
    distance = x % d
    do = k - (x // d)
    if do & 1:
        print(d - distance)
    else:
        print(distance)
else:
    print(x - k * d) import sys sys def input(): return sys.stdin.readline().rstrip("\r\n") input def List(): return list(map(int, input().split())) List def Num(): return int(input()) Num x, k, d = List() x List() List k d x = abs(x) x abs(x) abs x if d * k > x:
    distance = x % d
    do = k - (x // d)
    if do & 1:
        print(d - distance)
    else:
        print(distance)
else:
    print(x - k * d) d * k > x d * k d k x distance = x % d distance x % d x d do = k - (x // d) do k - (x // d) k x // d x d if do & 1:
        print(d - distance)
    else:
        print(distance) do & 1 do 1 print(d - distance) print d - distance d distance print(distance) print distance print(x - k * d) print x - k * d x k * d k d def input(): return sys.stdin.readline().rstrip("\r\n") def input(): return sys.stdin.readline().rstrip("\r\n") input k, d = List() List() k def List(): return list(map(int, input().split())) def List(): return list(map(int, input().split())) List d = List() List() d x = abs(x) abs(x) x distance = x % d x % d distance def Num(): return int(input()) def Num(): return int(input()) Num do = k - (x // d) k - (x // d) do x, k, d = List() List() x
import sys

def input(): return sys.stdin.readline().rstrip("\r\n")
def List(): return list(map(int, input().split()))
def Num(): return int(input())


x, k, d = List()
x = abs(x)
if d * k > x:
    distance = x % d
    do = k - (x // d)
    if do & 1:
        print(d - distance)
    else:
        print(distance)
else:
    print(x - k * d)
