Meeting Rooms II

MediumIntervals
Next
IntervalsHeapSweep Line

Given a list of meetings with start and end times, find the minimum number of conference rooms needed so that all meetings can take place. A meeting ending at time t does not conflict with one starting at t.

Input

Line 1: n. Next n lines: the start and end of each meeting.

Output

Print the minimum number of rooms required.

Constraints

1 <= n <= 10^4 0 <= start < end <= 10^6

Example 1
Input
3
0 30
5 10
15 20
Output
2

0-30 overlaps both others, so two rooms are needed.

Example 2
Input
2
7 10
2 4
Output
1

One room is enough.

Hints