Box Packing

아직 제출이 없습니다시간 제한1초메모리 제한256 MB

문제

An ordered pair of integers (x,y)(x, y) is called a box. A sequence of boxes (c_1,d_1), (c_2,d_2), , (c_m,d_m)(c\_1, d\_1), \ (c\_2, d\_2), \ \ldots, \ (c\_m, d\_m) is called a chain if the following inequalities hold: c_1c_2c_m,d_1d_2d_m.c\_1 \le c\_2 \le \ldots \le c\_m , \quad d\_1 \le d\_2 \le \ldots \le d\_m \text{.}

You are given nn boxes: (a_1,b_1), (a_2,b_2), , (a_n,b_n)(a\_1, b\_1), \ (a\_2, b\_2), \ \ldots, \ (a\_n, b\_n). Find the maximum number of boxes that you can select from them and split into no more than kk chains. You can reorder the boxes to form chains.

입력

The first line contains two integers, nn and kk (1n1051 \le n \le 10^5, 1k1001 \le k \le 100).

The ii-th of the following nn lines contains two integers, a_ia\_i and b_ib\_i (1a_i, b_i1091 \le a\_i, \ b\_i \le 10^9).

출력

Print one integer: the answer.