import kotlin.math.*
fun list() = readLine()!!.split(" ").map {it.toLong()}

fun main() {
	val (x,k,d) = list()
	val t = abs(x)/d

	if(t<=k) {
		abs(abs(x)-d*(t+(k-t)%2))
	} else {
		abs(x)-d*k
	}.let {println(it)}
}
