fun main() {
    // 文字列
//    var n = readLine()!!.toInt()
//    val x: String = readLine()!!
    // 数値
//    val int =readLine()!!.toInt()
    // 行
//    val list = readLine()!!.split(" ").map (String::toInt )
    var (x, k, d) = readLine()!!.split(" ").map(String::toLong)
//    val xys = List(n) {
////        readLine()!!.split(" ").map(String::toLong)
//        readLine()!!.toDouble()
//    }
    
    x=Math.abs(x)
    var ans=0L
    if (x / d >= k) {
        ans=x - k * d
    } else {
        val street_step = (x / d).toLong()
        val remainder_step = k - street_step
        if (remainder_step % 2 == 0L) {
            ans=x-(street_step*d)
        }else{
            ans=Math.abs(x-(street_step*d)-d)
        }
    }
    print(ans)

}