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

문제

A town gets all its electricity from solar power and a dam that provides hydroelectric power. These sources of energy are not always the most reliable, since the amount of sun and water can vary a lot from day to day. Luckily, the dam has a large reservoir that can store water in order to even out the supply of electricity from day to day.

You will be given information about the $n$ coming days. On the $i$'th day, the solar power station generates $s_i$ units of electricity. At the same time, $w_i$ units of water will flow into the reservoir. Each unit of water can be converted into one unit of electricity, and you can decide how much you want to convert and how much should be left in the reservoir. However, the reservoir can only hold $r$ units of water, so at the end of the day the amount of water in the reservoir cannot be larger than $r$. In the beginning of the first day the reservoir is empty.

On the first day, there is no water currently stored in the reservoir.  At the end of the last day, the dam will undergo maintenance and must be empty. In other words, all the water that flows into the dam during the $n$ days must at some point be converted to electricity.

Let $e_i$ be the amount of electricity produced on the $i$'th day. Note that $e_i = s_i + r_i$ where $r_i$ is how much water from the reservoir you converted on the $i$'th day. Your task is to find the minimum possible value of  $\max_i(e_i) - \min_i(e_i)$.

입력

The first line contains two integers $n$ and $r$ ($1 \leq n \leq 10^5$, $1 \leq r \leq 10^9$), the number of days and the amount of water the reservoir can hold.

The following $n$ lines each contain two integers $s_i$ and $w_i$ ($0 \leq s_i, w_i \leq 10^9$), the amount of electricity generated by the solar power station, and the amount of water that flowed into the reservoir on the $i$'th day.

출력

Output the minimum possible value of $\max_i(e_i) - \min_i(e_i)$.

예제 입력 1

3 1
4 2
2 0
5 1

예제 출력 1

3