import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val Array(a, b, c, d) = sc.nextLine.split(" ").map(_.toInt)
    if (b <= c) println(0)
    else println(Array(b, d).min - Array(a, c).max)

  }
}
