import scala.io.StdIn

object Main extends App {
  val time = Array.ofDim[Boolean](100)
  val Array(a, b, c, d) = StdIn.readLine.split(" ").map(_.toInt)

  for {
    i <- a until b
    j <- c until d
    if i == j
  } { time(i) = true }

  val ans = time.count(_ == true)

  println(ans)
}