x,k,d = list(map(int,input().split()))
x = abs(x)
point =x % d
num = x//d
if num<k:
    rest = k - num
    if rest%2==0:
        pass
    else:
        point = d -point
else:
    point = x - k*d
print(point) x,k,d = list(map(int,input().split())) x list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split k d x = abs(x) x abs(x) abs x point =x % d point x % d x d num = x//d num x//d x d if num<k:
    rest = k - num
    if rest%2==0:
        pass
    else:
        point = d -point
else:
    point = x - k*d num<k num k rest = k - num rest k - num k num if rest%2==0:
        pass
    else:
        point = d -point rest%2==0 rest%2 rest 2 0 point = d -point point d -point d point point = x - k*d point x - k*d x k*d k d print(point) print point point = x - k*d x - k*d point d = list(map(int,input().split())) list(map(int,input().split())) d point = d -point d -point point k,d = list(map(int,input().split())) list(map(int,input().split())) k x = abs(x) abs(x) x point =x % d x % d point rest = k - num k - num rest x,k,d = list(map(int,input().split())) list(map(int,input().split())) x num = x//d x//d num
x,k,d = list(map(int,input().split()))
x = abs(x)
point =x % d
num = x//d
if num<k:
    rest = k - num
    if rest%2==0:
        pass
    else:
        point = d -point
else:
    point = x - k*d
print(point)