(println
  (count (loop [s            (read-line)
                to-be-broken #{}]
           (if-let [l (not-empty s)]
             (let [[i1 i2] (->> (clojure.string/split l #"\s")
                                (map #(Integer/parseInt %)))
                   want-to-break (set (range i1 i2))
                   intersection  (clojure.set/intersection want-to-break to-be-broken)]
               (if (empty? intersection)
                 (recur (read-line)
                        to-be-broken)
                 (recur (read-line)
                        (let [diff (clojure.set/difference want-to-break to-be-broken)]
                          (cons (apply min diff) to-be-broken)))))
             to-be-broken))))
