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


X = abs(X)
a = K*D
if X >= a:
    result = X-a
else:
    b = X//D
    c = (X-b*D)
    d = abs(X-(b+1)*D)
    if c < d:
        if b%2==K%2:
            result = c
        else:
            result = d
    else:
        if (b+1)%2==K%2:
            result=d
        else:
            result=c

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


X = abs(X)
a = K*D
if X >= a:
    result = X-a
else:
    b = X//D
    c = (X-b*D)
    d = abs(X-(b+1)*D)
    if c < d:
        if b%2==K%2:
            result = c
        else:
            result = d
    else:
        if (b+1)%2==K%2:
            result=d
        else:
            result=c

print(result)