~/algor $ cat problems/saralash-kerakli-xonalar
Rooms needed
Medium
1000 ms
128 MB
66%
There are $n$ lessons: the $i$-th lesson starts at time $s_{i}$ and ends at time $e_{i}$. Only one lesson can take place in a room at a time; at the very moment one lesson ends, the next one may start in the same room. What is the smallest number of rooms needed to hold all the lessons?
Input
The first line contains a positive integer $n$. Each of the next $n$ lines contains two integers: $s_{i}$ and $e_{i}$.
Output
One integer — the number of rooms.
Note
$1 \le n \le 10^{5}$
$0 \le s_{i} \lt e_{i} \le 10^{9}$
Examples
Input #1
4 1 5 2 4 5 7 4 6
Output #1
2
Input #2
1 0 1
Output #2
1