x,k,d=gets.split.map(&:to_i)
if x==d && k%2==0
p d
exit
elsif x==d
p 0
end

result=[]
for i in 0..k
    if x>=0
    v=(x-k).abs
    result<<(x-k).abs
    x-=k
    else
    v=(x-k).abs
    result<<(x+k).abs
    x+=k
    end
    if result.count(v)>1
    break
    end
end



p result.min