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

if X == 0:
    print(0 if K % 2 == 0 else D)
elif X < 0:

    div = abs(X) // D
    tmp = X + D*div

    if div >= K:
        print(abs(X + D*K))
    elif div < K:
        K -= div
        print(abs(tmp) if K % 2 == 0 else abs(tmp+D))    

else:

    div = abs(X) // D
    tmp = X - D*div

    if div >= K:
        print(abs(X - D*K))
    elif div < K:
        K -= div
        print(abs(tmp) if K % 2 == 0 else abs(tmp-D))

 X, K, D = map(int, input().split()) X map(int, input().split()) map int input().split() ().split () input split K D if X == 0:
    print(0 if K % 2 == 0 else D)
elif X < 0:

    div = abs(X) // D
    tmp = X + D*div

    if div >= K:
        print(abs(X + D*K))
    elif div < K:
        K -= div
        print(abs(tmp) if K % 2 == 0 else abs(tmp+D))    

else:

    div = abs(X) // D
    tmp = X - D*div

    if div >= K:
        print(abs(X - D*K))
    elif div < K:
        K -= div
        print(abs(tmp) if K % 2 == 0 else abs(tmp-D)) X == 0 X 0 print(0 if K % 2 == 0 else D) print 0 if K % 2 == 0 else D K % 2 == 0 K % 2 K 2 0 0 D elif X < 0:

    div = abs(X) // D
    tmp = X + D*div

    if div >= K:
        print(abs(X + D*K))
    elif div < K:
        K -= div
        print(abs(tmp) if K % 2 == 0 else abs(tmp+D))     X < 0 X 0 div = abs(X) // D div abs(X) // D abs(X) abs X D tmp = X + D*div tmp X + D*div X D*div D div if div >= K:
        print(abs(X + D*K))
    elif div < K:
        K -= div
        print(abs(tmp) if K % 2 == 0 else abs(tmp+D))     div >= K div K print(abs(X + D*K)) print abs(X + D*K) abs X + D*K X D*K D K elif div < K:
        K -= div
        print(abs(tmp) if K % 2 == 0 else abs(tmp+D))     div < K div K K -= div K div print(abs(tmp) if K % 2 == 0 else abs(tmp+D)) print abs(tmp) if K % 2 == 0 else abs(tmp+D) K % 2 == 0 K % 2 K 2 0 abs(tmp) abs tmp abs(tmp+D) abs tmp+D tmp D div = abs(X) // D div abs(X) // D abs(X) abs X D tmp = X - D*div tmp X - D*div X D*div D div if div >= K:
        print(abs(X - D*K))
    elif div < K:
        K -= div
        print(abs(tmp) if K % 2 == 0 else abs(tmp-D)) div >= K div K print(abs(X - D*K)) print abs(X - D*K) abs X - D*K X D*K D K elif div < K:
        K -= div
        print(abs(tmp) if K % 2 == 0 else abs(tmp-D)) div < K div K K -= div K div print(abs(tmp) if K % 2 == 0 else abs(tmp-D)) print abs(tmp) if K % 2 == 0 else abs(tmp-D) K % 2 == 0 K % 2 K 2 0 abs(tmp) abs tmp abs(tmp-D) abs tmp-D tmp D K, D = map(int, input().split()) map(int, input().split()) K D = map(int, input().split()) map(int, input().split()) D K -= div div K K -= div div K div = abs(X) // D abs(X) // D div tmp = X + D*div X + D*div tmp div = abs(X) // D abs(X) // D div X, K, D = map(int, input().split()) map(int, input().split()) X tmp = X - D*div X - D*div tmp
X, K, D = map(int, input().split())

if X == 0:
    print(0 if K % 2 == 0 else D)
elif X < 0:

    div = abs(X) // D
    tmp = X + D*div

    if div >= K:
        print(abs(X + D*K))
    elif div < K:
        K -= div
        print(abs(tmp) if K % 2 == 0 else abs(tmp+D))    

else:

    div = abs(X) // D
    tmp = X - D*div

    if div >= K:
        print(abs(X - D*K))
    elif div < K:
        K -= div
        print(abs(tmp) if K % 2 == 0 else abs(tmp-D))


