import java.io.InputStreamReader
import java.io.BufferedReader

fun main(args: Array<String>) {
  val br = BufferedReader(InputStreamReader(System.`in`))
  val (A, B, C, D) = br.use { it.readLine().split(" ").map { it.toInt() } }

  val ans = BooleanArray(101, { i ->
      i in A..B-1 && i in C..D-1
    })
    .fold(0) { acc, isPushed ->
      if(isPushed) acc + 1
      else acc
    }

  println(ans)
}