import java.lang.Math.max
import java.lang.Math.min
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(max(0, min(B, D) - max(A, C)))
}
