x,k,d = map(int,input().split())

if x < 0:
    x *= -1
    
m = x // d

if k <= m:
    print(x - k*d)
    
else:
    x %= d
    y = abs(x-d)
    
    print([x,y][(k-m)%2]) x,k,d = map(int,input().split()) x map(int,input().split()) map int input().split() ().split () input split k d if x < 0:
    x *= -1
     x < 0 x 0 x *= -1 x -1 m = x // d m x // d x d if k <= m:
    print(x - k*d)
    
else:
    x %= d
    y = abs(x-d)
    
    print([x,y][(k-m)%2]) k <= m k m print(x - k*d) print x - k*d x k*d k d x %= d x d y = abs(x-d) y abs(x-d) abs x-d x d print([x,y][(k-m)%2]) print [x,y][(k-m)%2] [x,y] x y (k-m)%2 k-m k m 2 k,d = map(int,input().split()) map(int,input().split()) k x,k,d = map(int,input().split()) map(int,input().split()) x d = map(int,input().split()) map(int,input().split()) d x %= d d x y = abs(x-d) abs(x-d) y m = x // d x // d m x *= -1 -1 x
x,k,d = map(int,input().split())

if x < 0:
    x *= -1
    
m = x // d

if k <= m:
    print(x - k*d)
    
else:
    x %= d
    y = abs(x-d)
    
    print([x,y][(k-m)%2])