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.
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.
Print the maximum number of non-intersecting segments.
Example 1
Example 2