X, K, D = map(int,input().split())
X = abs(X)

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

if X > K*D:
    print( X - K*D )
else:
    a = X//D
    K -= a
    X -= D*a
    if K%2 == 0:
        print(X)
    else:
        print(abs(X-D))