import scala.io.StdIn

object Main extends App {

  val Array(a, b, c, d) = StdIn.readLine().split(" ").map(_.toInt)
  val start = if(a <= c && c <= b) c else if(c <= a && a <= d) a else 101
  val end = if(a <= d && d <= b) d else if(c <= b && b <= d) b else -1

  println(if((end - start) <= 0) 0 else end - start)

}
