
def main():
    X, K, D = map(int, input().split())
    X = abs(X)
    a = X // D
    ans = 0
    if a <= K:
        K -= a
        ans = X - D * a
        if K % 2 != 0:
            ans = abs(ans - D)
    else:
        ans = X - D * K
    print(ans)



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

def main():
    X, K, D = map(int, input().split())
    X = abs(X)
    a = X // D
    ans = 0
    if a <= K:
        K -= a
        ans = X - D * a
        if K % 2 != 0:
            ans = abs(ans - D)
    else:
        ans = X - D * K
    print(ans)



if __name__ == "__main__":
    main()