#P2684. 搞清洁

搞清洁

Description

FJ plans to assign his NN cows (1N2.5×104)(1 \le N \le 2.5\times 10^4) to do cleaning. He divides the day into T(1T106)T(1 \le T \le 10^6) time slots. He wants every time slot to have a cow cleaning, while using as few cows as possible.

Input Format

The first line contains two integers NN and TT.

The next NN lines each contain two integers, representing the time interval during which the ii-th cow can work (inclusive).

Output Format

Output the minimum number of cows needed so that every time slot has a cow working. If it is impossible, output -1.

3 10
1 7
3 6
8 10

2


Hint

Sample explanation:

There are 33 cows. The 11-st can work during 171\sim7, that is, starts at time 11 and ends at time 77 (time 77 is also covered). The 22-nd works during 363\sim6, and the 33-rd during 8108\sim10. Then only the 11-st and the 33-rd cows are needed to ensure every time slot is covered.

Translated by ChatGPT 5