import sys

input = sys.stdin.readline

def main():
    ans = 0
    x, k, d = map(int, input().split())
    ans = abs(x) - (d * min(k, abs(x)//d))
    t = k - abs(x)//d
    if t%2 != 0 and t > 0:
        ans = min(abs(ans-d), abs(ans+d))
    print(ans)

main()
 import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    ans = 0
    x, k, d = map(int, input().split())
    ans = abs(x) - (d * min(k, abs(x)//d))
    t = k - abs(x)//d
    if t%2 != 0 and t > 0:
        ans = min(abs(ans-d), abs(ans+d))
    print(ans) main ans = 0 ans 0 x, k, d = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split k d ans = abs(x) - (d * min(k, abs(x)//d)) ans abs(x) - (d * min(k, abs(x)//d)) abs(x) abs x d * min(k, abs(x)//d) d min(k, abs(x)//d) min k abs(x)//d abs(x) abs x d t = k - abs(x)//d t k - abs(x)//d k abs(x)//d abs(x) abs x d if t%2 != 0 and t > 0:
        ans = min(abs(ans-d), abs(ans+d))
     t%2 != 0 and t > 0 t%2 != 0 t%2 t 2 0 t > 0 t 0 ans = min(abs(ans-d), abs(ans+d)) ans min(abs(ans-d), abs(ans+d)) min abs(ans-d) abs ans-d ans d abs(ans+d) abs ans+d ans d print(ans) print ans main() main def main():
    ans = 0
    x, k, d = map(int, input().split())
    ans = abs(x) - (d * min(k, abs(x)//d))
    t = k - abs(x)//d
    if t%2 != 0 and t > 0:
        ans = min(abs(ans-d), abs(ans+d))
    print(ans) def main():
    ans = 0
    x, k, d = map(int, input().split())
    ans = abs(x) - (d * min(k, abs(x)//d))
    t = k - abs(x)//d
    if t%2 != 0 and t > 0:
        ans = min(abs(ans-d), abs(ans+d))
    print(ans) main input = sys.stdin.readline sys.stdin.readline input
import sys

input = sys.stdin.readline

def main():
    ans = 0
    x, k, d = map(int, input().split())
    ans = abs(x) - (d * min(k, abs(x)//d))
    t = k - abs(x)//d
    if t%2 != 0 and t > 0:
        ans = min(abs(ans-d), abs(ans+d))
    print(ans)

main()

