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

def judge():
    l = x if x > 0 else -x
    i = l//d
    r = l%d

    if (k - i)%2 == 0:
        print(r)
    else:
        print(d - r)
    '''
    if x > 0:
        for r in range(d):
            if (x - r)/d == (x - r)//d:
                i = (x - r)//d
                if (k - i)%2 == 0:
                    print(r)
                else:
                    print(d-r)
                exit()
    else:
        l = -x
        for r in range(d):
            if (l - r)/d == (l - r)//d:
                i = (l - r)//d
                if (k - i)%2 == 0:
                    print(r)
                else:
                    print(d-r)
                exit()
    '''

if x == 0:
    if k%2 == 0:
        print(0)
    else:
        print(d)
elif x < 0:
    if k*d + x > 0:
        judge()
    else:
        print(abs(k*d + x))
else:
    if x - k*d < 0:
        judge()
    else:
        print(abs(x - k*d)) x,k,d = map(int,input().split()) x map(int,input().split()) map int input().split() ().split () input split k d def judge():
    l = x if x > 0 else -x
    i = l//d
    r = l%d

    if (k - i)%2 == 0:
        print(r)
    else:
        print(d - r)
    '''
    if x > 0:
        for r in range(d):
            if (x - r)/d == (x - r)//d:
                i = (x - r)//d
                if (k - i)%2 == 0:
                    print(r)
                else:
                    print(d-r)
                exit()
    else:
        l = -x
        for r in range(d):
            if (l - r)/d == (l - r)//d:
                i = (l - r)//d
                if (k - i)%2 == 0:
                    print(r)
                else:
                    print(d-r)
                exit()
    ''' judge l = x if x > 0 else -x l x if x > 0 else -x x > 0 x 0 x -x x i = l//d i l//d l d r = l%d r l%d l d if (k - i)%2 == 0:
        print(r)
    else:
        print(d - r)
     (k - i)%2 == 0 (k - i)%2 k - i k i 2 0 print(r) print r print(d - r) print d - r d r '''
    if x > 0:
        for r in range(d):
            if (x - r)/d == (x - r)//d:
                i = (x - r)//d
                if (k - i)%2 == 0:
                    print(r)
                else:
                    print(d-r)
                exit()
    else:
        l = -x
        for r in range(d):
            if (l - r)/d == (l - r)//d:
                i = (l - r)//d
                if (k - i)%2 == 0:
                    print(r)
                else:
                    print(d-r)
                exit()
    ''' if x == 0:
    if k%2 == 0:
        print(0)
    else:
        print(d)
elif x < 0:
    if k*d + x > 0:
        judge()
    else:
        print(abs(k*d + x))
else:
    if x - k*d < 0:
        judge()
    else:
        print(abs(x - k*d)) x == 0 x 0 if k%2 == 0:
        print(0)
    else:
        print(d) k%2 == 0 k%2 k 2 0 print(0) print 0 print(d) print d elif x < 0:
    if k*d + x > 0:
        judge()
    else:
        print(abs(k*d + x)) x < 0 x 0 if k*d + x > 0:
        judge()
    else:
        print(abs(k*d + x)) k*d + x > 0 k*d + x k*d k d x 0 judge() judge print(abs(k*d + x)) print abs(k*d + x) abs k*d + x k*d k d x if x - k*d < 0:
        judge()
    else:
        print(abs(x - k*d)) x - k*d < 0 x - k*d x k*d k d 0 judge() judge print(abs(x - k*d)) print abs(x - k*d) abs x - k*d x k*d k d x,k,d = map(int,input().split()) map(int,input().split()) x k,d = map(int,input().split()) map(int,input().split()) k d = map(int,input().split()) map(int,input().split()) d def judge():
    l = x if x > 0 else -x
    i = l//d
    r = l%d

    if (k - i)%2 == 0:
        print(r)
    else:
        print(d - r)
    '''
    if x > 0:
        for r in range(d):
            if (x - r)/d == (x - r)//d:
                i = (x - r)//d
                if (k - i)%2 == 0:
                    print(r)
                else:
                    print(d-r)
                exit()
    else:
        l = -x
        for r in range(d):
            if (l - r)/d == (l - r)//d:
                i = (l - r)//d
                if (k - i)%2 == 0:
                    print(r)
                else:
                    print(d-r)
                exit()
    ''' def judge():
    l = x if x > 0 else -x
    i = l//d
    r = l%d

    if (k - i)%2 == 0:
        print(r)
    else:
        print(d - r)
    '''
    if x > 0:
        for r in range(d):
            if (x - r)/d == (x - r)//d:
                i = (x - r)//d
                if (k - i)%2 == 0:
                    print(r)
                else:
                    print(d-r)
                exit()
    else:
        l = -x
        for r in range(d):
            if (l - r)/d == (l - r)//d:
                i = (l - r)//d
                if (k - i)%2 == 0:
                    print(r)
                else:
                    print(d-r)
                exit()
    ''' judge
x,k,d = map(int,input().split())

def judge():
    l = x if x > 0 else -x
    i = l//d
    r = l%d

    if (k - i)%2 == 0:
        print(r)
    else:
        print(d - r)
    '''
    if x > 0:
        for r in range(d):
            if (x - r)/d == (x - r)//d:
                i = (x - r)//d
                if (k - i)%2 == 0:
                    print(r)
                else:
                    print(d-r)
                exit()
    else:
        l = -x
        for r in range(d):
            if (l - r)/d == (l - r)//d:
                i = (l - r)//d
                if (k - i)%2 == 0:
                    print(r)
                else:
                    print(d-r)
                exit()
    '''

if x == 0:
    if k%2 == 0:
        print(0)
    else:
        print(d)
elif x < 0:
    if k*d + x > 0:
        judge()
    else:
        print(abs(k*d + x))
else:
    if x - k*d < 0:
        judge()
    else:
        print(abs(x - k*d))
