fun main(args: Array<String>) {
    val (A, B, C) = readLine()!!.split(" ").map { it.toLong() }
    val s = listOf(A, B, C)
    val max = s.max()!!
    val mid = s.sorted()[1]
    val min = s.min()!!

    var count = 0

    var minP = 0
    while (min + 1 + minP < mid) {
        count++
        minP += 2
    }

    if (mid != min + minP) {
        count += 2
    }

    var midP = 0
    while (mid + midP < max) {
        count++
        midP++
    }

    println(count)
}