#P1034D. Intervals of Intervals

    ID: 5139 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 10 Uploaded By: Tags>binary searchdata structurestwo pointers*3500

Intervals of Intervals

Description

Little D is a friend of Little C who loves intervals very much instead of number "33".

Now he has nn intervals on the number axis, the ii-th of which is [ai,bi][a_i,b_i].

Only the nn intervals can not satisfy him. He defines the value of an interval of intervals [l,r][l,r] (1lrn1 \leq l \leq r \leq n, ll and rr are both integers) as the total length of the union of intervals from the ll-th to the rr-th.

He wants to select exactly kk different intervals of intervals such that the sum of their values is maximal. Please help him calculate the maximal sum.

First line contains two integers nn and kk (1n31051 \leq n \leq 3 \cdot 10^5, 1kmin{n(n+1)2,109}1 \leq k \leq \min\{\frac{n(n+1)}{2},10^9\}) — the number of intervals Little D has and the number of intervals of intervals he will select.

Each of the next nn lines contains two integers aia_i and bib_i, the ii-th line of the nn lines describing the ii-th interval (1ai<bi1091 \leq a_i < b_i \leq 10^9).

Print one integer — the maximal sum of values Little D can get.

Input

First line contains two integers nn and kk (1n31051 \leq n \leq 3 \cdot 10^5, 1kmin{n(n+1)2,109}1 \leq k \leq \min\{\frac{n(n+1)}{2},10^9\}) — the number of intervals Little D has and the number of intervals of intervals he will select.

Each of the next nn lines contains two integers aia_i and bib_i, the ii-th line of the nn lines describing the ii-th interval (1ai<bi1091 \leq a_i < b_i \leq 10^9).

Output

Print one integer — the maximal sum of values Little D can get.

Sample Input 1

2 1
1 3
2 4

Sample Output 1

3

Sample Input 2

3 3
1 4
5 7
3 6

Sample Output 2

15

Note

For the first example, Little D will select [1,2][1,2], the union of the first interval and the second interval is [1,4][1,4], whose length is 33.

For the second example, Little D will select [1,2][1,2], [2,3][2,3] and [1,3][1,3], the answer is 5+6+4=155+6+4=15.