Contests
Time limit1.5sMemory limit1024 MB
Given N contests as day intervals, find the fewest non-overlapping contests Hyeongseop can still win after K-1 rivals each pick a non-overlapping set of contests.
Problem
Hyeongseop is the -th best programmer in the world, but he wants to win as many programming contests as possible so that his name becomes known. When Hyeongseop enters a contest, he always loses to anyone better than him and always beats anyone worse than him. So Hyeongseop can win a contest only when nobody better than him takes part in it, and in such a contest he always wins.
Across the world, programming contests are held, and contest runs from day to day . Contests held at different venues, so no one can enter two contests whose periods overlap. Hyeongseop knows in advance which contests the people better than him will enter. He picks the contests that none of those people enter, and he enters as many of them as he can so that he wins as many as possible.
If the people enter contests well, Hyeongseop has few contests left to win. He wants to know the largest number of contests he can win in that case. Write a program that finds the number of contests Hyeongseop can win when the information about the contests is given.
Input
The first line contains the number of contests () and Hyeongseop's rank ().
Each of the next lines contains the start day and the end day of a contest ().
Output
Print the number of contests Hyeongseop can win when the people enter contests in a way that makes this number as small as possible.