open Printf
open Scanf

let () =
        let (a, b, c, d) = scanf "%d %d %d %d" (fun a b c d -> (a, b, c, d)) in
        printf "%d\n"
        (let x = (min b d) - (max a c) in
        (if x < 0 then 0 else x))
