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

straight = min(k, math.floor(x / d))

k -= straight
x -= straight * d

if(k % 2 == 0):
    print(x)
else:
    print(abs(x - d))  import math math x, k, d = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split k d x = abs(x) x abs(x) abs x straight = min(k, math.floor(x / d)) straight min(k, math.floor(x / d)) min k math.floor(x / d) math.floor math floor x / d x d k -= straight k straight x -= straight * d x straight * d straight d if(k % 2 == 0):
    print(x)
else:
    print(abs(x - d))  k % 2 == 0 k % 2 k 2 0 print(x) print x print(abs(x - d)) print abs(x - d) abs x - d x d straight = min(k, math.floor(x / d)) min(k, math.floor(x / d)) straight x, k, d = map(int, input().split()) map(int, input().split()) x d = map(int, input().split()) map(int, input().split()) d k, d = map(int, input().split()) map(int, input().split()) k x = abs(x) abs(x) x k -= straight straight k x -= straight * d straight * d x
import math
x, k, d = map(int, input().split())
x = abs(x)

straight = min(k, math.floor(x / d))

k -= straight
x -= straight * d

if(k % 2 == 0):
    print(x)
else:
    print(abs(x - d)) 