Module module1
  Sub main()
    Dim read() as string = split(Console.ReadLine())
    Dim X = read(0)
    Dim K　= read(1)
    Dim D = read(2)
    
    if X < 0 then
      X = -X
    end if
    
    dim n = X \ D
    if n >= K then 
      Dim ans = X - D * K
      if ans < 0 then
        ans = -ans
      end if
      Console.WriteLine(ans)
    else
      if K mod 2 = 0 then
        Console.Write(X)
      else
        Console.Write(D-X)
      end if
    end if
  end sub
end module