Setting the video

Professor Oak is a great fan of Takeshi’s castle. So much, that he has bought a satellite antenna to watch the show in several European channels. Professor Oak has a guide of all the channels of Europe, and wants to set his video to record as many episodes as possible. But it is not easy: The video only can record a channel at a time. Moreover, the episodes can have different lengths (depending on how they are edited, the advertiments, etc).

Can you help professor Oak? Write a program that, given the beginning time and end time of the broadcast of all the episodes of Takeshi’s castle in all the european channels during several days, computes the maximum number of episodes that can be recorded every day.

Input

Input consists of several cases. Each case has a natural number 1n1051 \le n \le 10^5 followed by nn pairs (i1,f1),,(in,fn)(i_1, f_1), \dots, (i_n, f_n) of natural numbers that indicate the beginning time and the end time, both of them included, of each episode of a day. For any jj between 1 and nn, assume 0ijfj1090 \le i_j \le f_j \le 10^9.

Output

For each case of the input, print a line with the maximum number of complete episodes that professor Oak will be able to record that day.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:01:26.205Z

© Jutge.org, 2006–2026.
https://jutge.org