import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

x,k,d = map(int, input().split())

x = abs(x)

if x == 0:
    if k % 2 == 0:
        print(0)
        exit()
    else:
        print(abs(d))
        exit()

bai = x//d

if bai >= k:
    print(x-k*d)
    exit()
else:
    x -= bai*d
    if (k-bai)%2==0:
        print(x)
        exit()
    else:
        print(abs(x-d))

 import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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 == 0:
    if k % 2 == 0:
        print(0)
        exit()
    else:
        print(abs(d))
        exit() x == 0 x 0 if k % 2 == 0:
        print(0)
        exit()
    else:
        print(abs(d))
        exit() k % 2 == 0 k % 2 k 2 0 print(0) print 0 exit() exit print(abs(d)) print abs(d) abs d exit() exit bai = x//d bai x//d x d if bai >= k:
    print(x-k*d)
    exit()
else:
    x -= bai*d
    if (k-bai)%2==0:
        print(x)
        exit()
    else:
        print(abs(x-d)) bai >= k bai k print(x-k*d) print x-k*d x k*d k d exit() exit x -= bai*d x bai*d bai d if (k-bai)%2==0:
        print(x)
        exit()
    else:
        print(abs(x-d)) (k-bai)%2==0 (k-bai)%2 k-bai k bai 2 0 print(x) print x exit() exit print(abs(x-d)) print abs(x-d) abs x-d x d k,d = map(int, input().split()) map(int, input().split()) k input = sys.stdin.readline sys.stdin.readline input bai = x//d x//d bai x -= bai*d bai*d x x = abs(x) abs(x) x x,k,d = map(int, input().split()) map(int, input().split()) x d = map(int, input().split()) map(int, input().split()) d
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

x,k,d = map(int, input().split())

x = abs(x)

if x == 0:
    if k % 2 == 0:
        print(0)
        exit()
    else:
        print(abs(d))
        exit()

bai = x//d

if bai >= k:
    print(x-k*d)
    exit()
else:
    x -= bai*d
    if (k-bai)%2==0:
        print(x)
        exit()
    else:
        print(abs(x-d))


