Segments#4786

Segments

1 segundo
128 megabytes
Muy fácil

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.

Entrada

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.

Salida

Print the maximum number of non-intersecting segments.

Ejemplos

Ejemplo 1

Loading
Loading

Ejemplo 2

Loading
Loading