Training
시간 제한1초메모리 제한2048 MB
고정된 순서로 주어진 n개의 문제 각각에 대해, 현재 실력이 [l, r] 범위에 들어갈 때 풀면 실력이 1 오른다. 풀 문제를 골라 최종 실력을 최대로 만든다.
문제
Ashley is training for a programming contest on Brandon's Online Judge. Brandon's Online Judge has a new feature which allows Ashley's coach, Tom, to load a list of problems for Ashley.
Tom has curated some problems for Ashley to work on. Each problem has two integers as a lower skill bound and an upper skill bound. Each programmer has an integer skill level. If someone with a skill level between the lower and upper bounds of a problem (inclusive), and they solve that problem, then his/her skill level goes up by .
Ashley will train on Tom's curated list of problems as follows -- she will look at the first problem on the list and either solve it or skip it. She will repeat this for every problem on the list in the order Tom loaded the problems. Once she has skipped a problem, she can never go back to it.
Compute the maximum skill level Ashley can have if she chooses to solve or skip problems optimally.
입력
The first line contains two integers and , where is the number of problems Tom has curated for Ashley, and is Ashley's current skill level.
Each of the next lines contains two integers and . These are the lower () and upper () skill bounds on each of Tom's problems, in the order that Tom loaded them.
출력
Output a single integer, which is the maximum skill level Ashley can attain.