Recording the Moolympics
InterviewTime limit1sMemory limit128 MB
Select the largest set of programs that two tuners can record when one tuner cannot record overlapping programs.
Problem
Farmer John likes every cold-weather sport, and he likes the events with cows in them most of all. So he wants to record as much of this winter's Moolympics as he can.
The Moolympics broadcast schedule has programs, and every program has a fixed start time and end time. Farmer John's recorder has two tuners, so he can record two programs at the same time. A single tuner cannot record two programs whose times overlap, but it can go straight on to a program that starts at the exact moment the previous one ends.
Write a program that finds the largest number of programs Farmer John can record.
Input
The first line contains the number of programs ().
Each of the next lines contains the start time and the end time of one program, separated by a space. Both values are integers between and .
Output
Print the largest number of programs Farmer John can record.