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


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


if __name__ == '__main__':
    main()
