X,K,D = [int(x) for x in input().split()]

if D * K < abs(X):
    print(abs(X) - D * K)
else:
    if (K - abs(X) // D) % 2 == 0:
        print(abs(X) % D)
    else:
        print(D - abs(X) % D) int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x X,K,D = [int(x) for x in input().split()] X [int(x) for x in input().split()] K D if D * K < abs(X):
    print(abs(X) - D * K)
else:
    if (K - abs(X) // D) % 2 == 0:
        print(abs(X) % D)
    else:
        print(D - abs(X) % D) D * K < abs(X) D * K D K abs(X) abs X print(abs(X) - D * K) print abs(X) - D * K abs(X) abs X D * K D K if (K - abs(X) // D) % 2 == 0:
        print(abs(X) % D)
    else:
        print(D - abs(X) % D) (K - abs(X) // D) % 2 == 0 (K - abs(X) // D) % 2 K - abs(X) // D K abs(X) // D abs(X) abs X D 2 0 print(abs(X) % D) print abs(X) % D abs(X) abs X D print(D - abs(X) % D) print D - abs(X) % D D abs(X) % D abs(X) abs X D K,D = [int(x) for x in input().split()] [int(x) for x in input().split()] K D = [int(x) for x in input().split()] [int(x) for x in input().split()] D X,K,D = [int(x) for x in input().split()] [int(x) for x in input().split()] X
X,K,D = [int(x) for x in input().split()]

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