LearnPy Hub
← Arena
AdvancedRating 1700

Cover the Video With Clips

Clips cover intervals [s, e] of a video lasting T seconds. Choose the fewest clips whose union covers [0, T] (clips may overlap and can be cut). Print the number, or -1.

Input

n and T; then n lines 's e'.

Output

One integer.

Sample 1

Input
6 10
0 2
4 6
8 10
1 9
1 5
5 9
Output
3

Sample 2

Input
2 5
0 1
1 2
Output
-1
solution.py
Output appears here
Cover the Video With Clips · Python Arena problem · LearnPy Hub