fun main(arr:Array<String>) {
    val numbers = readLine()!!.split(" ").map { it.toInt() }.sortedDescending().toMutableList()
    val diff = numbers.max()!! * numbers.size - numbers.sum()
    val ans = diff / 2 + (diff%2)*2
    println(ans)
}
