시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB32221688.889%

문제

Rafael lives in an ideal egalitarian society: all jobs offer identical payment rates and you only have to work at a job that you find personally fulfilling. Unfortunately, even such a utopia can’t account for the fact that Rafael is not very skilled at anything.

To compensate for this, Rafael turns to contractor work, where potential employers lack the time to realize how unqualified for the job he is. Even then, given his lack of qualifications for these contractor positions, he must expend money on acquiring fake cover letters in order to even get hired.

Rafael has a choice of N contractor jobs available to him. The i-th job starts at day ℓi, ends at the end of day ri and pays exactly S gold coins a day. Rafael is a really bad worker, and cannot work two jobs at the same time; moreover, he can only start job i at day ℓi but, once hired, he can choose to quit at the end of any day, keeping the money from the days he worked (including the last one), and being able to start another job from the next day on, but not on the same day. Additionally, Rafael knows that it would cost ci gold coins to buy a fake cover letter for job i. Aware of his inabilities and the need for fake cover letters, Rafael always has enough savings to pay for any number of cover letters he might need, even before working any of the N jobs.

Given the description of the available jobs, what is the maximum profit that Rafael can attain, factoring in the expenses for the required fake cover letters?

입력

The first line contains two integers N (1 ≤ N ≤ 106) and S (1 ≤ S ≤ 109), representing the number of jobs available and what is their daily pay.

Each of the following N lines contains three integers: ℓi, ri and ci (1 ≤ ℓi ≤ ri ≤ 109, 1 ≤ ci ≤ 109), representing the start date, end date, and cost of obtaining a fake cover letter for job i, respectively.

출력

Output a single line with an integer indicating the amount of money Rafael can make after all the jobs are over.

예제 입력 1

3 3
1 5 10
2 10 4
5 15 1

예제 출력 1

37

It is optimal to start the second job, then switch to the third one, for a total of 14×3−4−1 = 37 gold coins.

예제 입력 2

3 5
1 1 3
2 3 4
3 3 1

예제 출력 2

8

예제 입력 3

1 1000
1 1 654

예제 출력 3

346

Even though he has to take money from savings to buy the fake cover letter he can still make some profit.

예제 입력 4

1 5
1 3 20

예제 출력 4

0

Not worth spending money on the fake cover letter for this job.