(defn input []
  (->> (clojure.string/split (read-line) #"\s")
    (map #(Integer/parseInt %))))

(defn TwoSwithches [[A B C D]]
  (let [t (- (min B D) (max A C))]
    (if (pos? t) t 0)))

(-> (input)
  TwoSwithches
  println)