import java.util.*

val sc = Scanner(System.`in`)
val A = sc.nextInt()
val B = sc.nextInt()
val C = sc.nextInt()
val D = sc.nextInt()

fun main(args: Array<String>) {
    println(Math.max(0, arrayOf(B - A, D - C, B - C, D - A).min()!!))
}
