x, k, d = map(int, input().split())
x = abs(x)
if x > k*d:
    print(x-k*d)
else:
    p = x//d
    c = k-p
    if p == 0 or p==1:
          for i in range(1,k+1):
            p2 = x-i*d
            c = k-i
            if p2 <= 0:
                if c%2 != 0:
                    print(abs(d+p2))
                    break
                elif c%2 == 0:
                    print(abs(p2))
                    break
    elif (c%2 == 0):
        print(abs(x-p*d))
    else:
        print(abs(d-abs(x-p*d))) 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 > k*d:
    print(x-k*d)
else:
    p = x//d
    c = k-p
    if p == 0 or p==1:
          for i in range(1,k+1):
            p2 = x-i*d
            c = k-i
            if p2 <= 0:
                if c%2 != 0:
                    print(abs(d+p2))
                    break
                elif c%2 == 0:
                    print(abs(p2))
                    break
    elif (c%2 == 0):
        print(abs(x-p*d))
    else:
        print(abs(d-abs(x-p*d))) x > k*d x k*d k d print(x-k*d) print x-k*d x k*d k d p = x//d p x//d x d c = k-p c k-p k p if p == 0 or p==1:
          for i in range(1,k+1):
            p2 = x-i*d
            c = k-i
            if p2 <= 0:
                if c%2 != 0:
                    print(abs(d+p2))
                    break
                elif c%2 == 0:
                    print(abs(p2))
                    break
    elif (c%2 == 0):
        print(abs(x-p*d))
    else:
        print(abs(d-abs(x-p*d))) p == 0 or p==1 p == 0 p 0 p==1 p 1 for i in range(1,k+1):
            p2 = x-i*d
            c = k-i
            if p2 <= 0:
                if c%2 != 0:
                    print(abs(d+p2))
                    break
                elif c%2 == 0:
                    print(abs(p2))
                    break
     i range(1,k+1) range 1 k+1 k 1 p2 = x-i*d p2 x-i*d x i*d i d c = k-i c k-i k i if p2 <= 0:
                if c%2 != 0:
                    print(abs(d+p2))
                    break
                elif c%2 == 0:
                    print(abs(p2))
                    break
     p2 <= 0 p2 0 if c%2 != 0:
                    print(abs(d+p2))
                    break
                elif c%2 == 0:
                    print(abs(p2))
                    break
     c%2 != 0 c%2 c 2 0 print(abs(d+p2)) print abs(d+p2) abs d+p2 d p2 break elif c%2 == 0:
                    print(abs(p2))
                    break
     c%2 == 0 c%2 c 2 0 print(abs(p2)) print abs(p2) abs p2 break elif (c%2 == 0):
        print(abs(x-p*d))
     c%2 == 0 c%2 c 2 0 print(abs(x-p*d)) print abs(x-p*d) abs x-p*d x p*d p d print(abs(d-abs(x-p*d))) print abs(d-abs(x-p*d)) abs d-abs(x-p*d) d abs(x-p*d) abs x-p*d x p*d p d x = abs(x) abs(x) x p2 = x-i*d x-i*d p2 c = k-i k-i c k, d = map(int, input().split()) map(int, input().split()) k x, k, d = map(int, input().split()) map(int, input().split()) x c = k-p k-p c d = map(int, input().split()) map(int, input().split()) d p = x//d x//d p
x, k, d = map(int, input().split())
x = abs(x)
if x > k*d:
    print(x-k*d)
else:
    p = x//d
    c = k-p
    if p == 0 or p==1:
          for i in range(1,k+1):
            p2 = x-i*d
            c = k-i
            if p2 <= 0:
                if c%2 != 0:
                    print(abs(d+p2))
                    break
                elif c%2 == 0:
                    print(abs(p2))
                    break
    elif (c%2 == 0):
        print(abs(x-p*d))
    else:
        print(abs(d-abs(x-p*d)))