Baq is a very diligent student who is faced with the difficult task of choosing subjects for the next year. Since he is very interested in learning mathematics, he wants to choose the maximum number of subjects possible. Additionally, he does not want to skip any classes, so he does not want any subjects to overlap (although he has no problem attending multiple subjects consecutively). Classes must start and end on the hour, but since Baq lives in a somewhat strange universe, days do not necessarily have 24 hours.
Knowing the start and end times of each subject, can you determine the maximum number of subjects that Baq will be able to take?
The input consists of several cases. Each case starts with $$$n$$$, the number of subjects offered, and $$$m$$$, the number of hours in a day. This is followed by $$$n$$$ lines with two integers $$$a_i$$$ $$$b_i$$$, representing the start and end times of the i-th subject. It is guaranteed that $$$0 \leq a_i \lt b_i \leq m$$$.
For each case, print a line with the maximum number of subjects that can be taken.
A (5 points): Cases where $$$n = 2$$$, $$$1 \leq m \leq 10$$$.
B (5 points): Cases where $$$0 \leq n \leq 10$$$, $$$m = 2$$$.
C (15 points): Cases where $$$0 \leq n \leq 10$$$, $$$1 \leq m \leq 10$$$.
D (30 points): Cases where $$$0 \leq n \leq 1000$$$, $$$1 \leq m \leq 1000$$$.
E (45 points): Cases where $$$0 \leq n \leq 5 \cdot 10^5$$$, $$$1 \leq m \leq 5 \cdot 10^5$$$.
3 2 0 1 0 2 1 2 2 2 0 1 0 2 4 8 0 1 1 2 3 7 4 7
2 1 3
| Name |
|---|


