object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val a, b, c, d = sc.nextInt

  val res = (0 to 100).foldLeft(0) { (acc, n) =>
    if (a <= n && n < b && c <= n && n < d) acc+1 else acc
  }
  println(res)
}