Segments#4786

Segments

1 second
128 megabytes
Very easy

Segments are given on a line. Determine the maximum number of segments that can be selected such that no two of them intersect. All segments are open.

Input

The first line contains the number of segments (1 \le n \le 10^5). Each of the next lines contains two integers, l_i and r_i (1 \le l_i < r_i \le 10^9), representing the starting and ending points of the -th segment.

Output

Print the maximum number of non-intersecting segments.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading