#abc080d. [abc080_d]Recording
[abc080_d]Recording
Problem Statement
Joisino is planning to record TV programs with recorders.
The TV can receive channels numbered through .
The -th program that she wants to record will be broadcast from time to time (including time but not ) on Channel .
Here, there will never be more than one program that are broadcast on the same channel at the same time.
When the recorder is recording a channel from time to time (including time but not ), it cannot record other channels from time to time (including time but not ).
Find the minimum number of recorders required to record the channels so that all the programs are completely recorded.
Constraints
- If and , either or .
- All input values are integers.
Input
Input is given from Standard Input in the following format:
Output
When the minimum required number of recorders is , print the value of .
Sample Input 1
3 2
1 7 2
7 8 1
8 12 1
Sample Output 1
2
Two recorders can record all the programs, for example, as follows:
- With the first recorder, record Channel from time to time . The first program will be recorded. Note that this recorder will be unable to record other channels from time to time .
- With the second recorder, record Channel from time to time . The second and third programs will be recorded. Note that this recorder will be unable to record other channels from time to time .
Sample Input 2
3 4
1 3 2
3 4 4
1 4 3
Sample Output 2
3
There may be a channel where there is no program to record.
Sample Input 3
9 4
56 60 4
33 37 2
89 90 3
32 43 1
67 68 3
49 51 3
31 32 3
70 71 1
11 12 3
Sample Output 3
2