def solve():
    X,K,D = [int(i) for i in input().split()]
    abs_X = abs(X)
    if D*K <= abs_X:
        print(abs_X - D*K)
    else:
        steps2pivot = abs_X // D
        abs_X -= steps2pivot * D
        rest = K - steps2pivot
        if rest % 2 == 0:
            print(abs_X)
        else:
            print(abs(abs_X-D))

if __name__ == "__main__":
    solve() def solve():
    X,K,D = [int(i) for i in input().split()]
    abs_X = abs(X)
    if D*K <= abs_X:
        print(abs_X - D*K)
    else:
        steps2pivot = abs_X // D
        abs_X -= steps2pivot * D
        rest = K - steps2pivot
        if rest % 2 == 0:
            print(abs_X)
        else:
            print(abs(abs_X-D)) solve int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i X,K,D = [int(i) for i in input().split()] X [int(i) for i in input().split()] K D abs_X = abs(X) abs_X abs(X) abs X if D*K <= abs_X:
        print(abs_X - D*K)
    else:
        steps2pivot = abs_X // D
        abs_X -= steps2pivot * D
        rest = K - steps2pivot
        if rest % 2 == 0:
            print(abs_X)
        else:
            print(abs(abs_X-D)) D*K <= abs_X D*K D K abs_X print(abs_X - D*K) print abs_X - D*K abs_X D*K D K steps2pivot = abs_X // D steps2pivot abs_X // D abs_X D abs_X -= steps2pivot * D abs_X steps2pivot * D steps2pivot D rest = K - steps2pivot rest K - steps2pivot K steps2pivot if rest % 2 == 0:
            print(abs_X)
        else:
            print(abs(abs_X-D)) rest % 2 == 0 rest % 2 rest 2 0 print(abs_X) print abs_X print(abs(abs_X-D)) print abs(abs_X-D) abs abs_X-D abs_X D if __name__ == "__main__":
    solve() __name__ == "__main__" __name__ "__main__" solve() solve def solve():
    X,K,D = [int(i) for i in input().split()]
    abs_X = abs(X)
    if D*K <= abs_X:
        print(abs_X - D*K)
    else:
        steps2pivot = abs_X // D
        abs_X -= steps2pivot * D
        rest = K - steps2pivot
        if rest % 2 == 0:
            print(abs_X)
        else:
            print(abs(abs_X-D)) def solve():
    X,K,D = [int(i) for i in input().split()]
    abs_X = abs(X)
    if D*K <= abs_X:
        print(abs_X - D*K)
    else:
        steps2pivot = abs_X // D
        abs_X -= steps2pivot * D
        rest = K - steps2pivot
        if rest % 2 == 0:
            print(abs_X)
        else:
            print(abs(abs_X-D)) solve
def solve():
    X,K,D = [int(i) for i in input().split()]
    abs_X = abs(X)
    if D*K <= abs_X:
        print(abs_X - D*K)
    else:
        steps2pivot = abs_X // D
        abs_X -= steps2pivot * D
        rest = K - steps2pivot
        if rest % 2 == 0:
            print(abs_X)
        else:
            print(abs(abs_X-D))

if __name__ == "__main__":
    solve()