
import java.util.*

fun main(argv : Array<String>){
    
    val scan = Scanner(System.`in`)
    
    //
    val A = scan.nextInt()
    val B = scan.nextInt()
    val C = scan.nextInt()
    val D = scan.nextInt()

    //
    when{
        C>B -> println(0)
        A>D -> println(0)
        else -> {
            var a = intArrayOf(A,B,C,D)
            Arrays.sort(a)
            println(a[2]-a[1])
        }
    }
}

