Entertainment Box
InterviewTime limit2sMemory limit256 MB
Schedule the most TV shows on k recorders so no recorder tapes overlapping shows.
Problem
Ada, Bertrand and Charles argue often about which TV shows to watch. To cut down on the fights they bought a video recorder. The recorder tapes different shows at the same time, and as soon as a show being taped in one of its slots ends, that slot is ready to tape another show.
The three friends want to know how many shows they can record in one day. You get today's TV guide and the number of shows the machine tapes at once. Find the largest number of shows they can record. Only shows taped from start to finish count.
Input
The first line contains two integers and (). Each of the next lines contains two integers and , meaning that show starts at time and finishes at time . Two shows and with can be taped in the same slot without conflict. It holds that .
Output
Print one line with a single integer, the maximum number of full shows from the guide that the recorder can tape.