object Main {
  def main(args: Array[String]): Unit = {
    val Array( start, move_count, move_dis ) = scala.io.StdIn.readLine.split( " " ).map{ _.toLong }
    val switch_move_count = Math.abs( start )/move_dis

    if( switch_move_count >= move_count ) println( Math.abs( start ) - move_count*move_dis )
    else {
      val min_diff          = Math.abs( start ) - move_dis*switch_move_count
      val min_diff_switched = move_dis - min_diff
      if( ( move_count - switch_move_count )%2 == 0 ) println( min_diff )
      else                                            println( min_diff_switched )
    }

  }
}