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

if x >= k*d:
    print(x - d*k)
else:
    e = x//d
    k -= e
    x %= d
    if k % 2 == 0:
        print(x)
    else:
        print(d-x) 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 if x >= k*d:
    print(x - d*k)
else:
    e = x//d
    k -= e
    x %= d
    if k % 2 == 0:
        print(x)
    else:
        print(d-x) x >= k*d x k*d k d print(x - d*k) print x - d*k x d*k d k e = x//d e x//d x d k -= e k e x %= d x d if k % 2 == 0:
        print(x)
    else:
        print(d-x) k % 2 == 0 k % 2 k 2 0 print(x) print x print(d-x) print d-x d x x = abs(X) abs(X) x x %= d d x k,d = map(int,input().split()) map(int,input().split()) k e = x//d x//d e X,k,d = map(int,input().split()) map(int,input().split()) X d = map(int,input().split()) map(int,input().split()) d k -= e e k
X,k,d = map(int,input().split())
x = abs(X)

if x >= k*d:
    print(x - d*k)
else:
    e = x//d
    k -= e
    x %= d
    if k % 2 == 0:
        print(x)
    else:
        print(d-x)
