题目描述
Problem Description
A-san is a master of yakiniku (grilled meat).
A-san has $ N $ pieces of meat, a long grill net of length $ M $, and charcoal to grill the meat. The length of meat $ i $ is $ L_i $. Let's denote one end of the grill net as coordinate $ 0 $ and the other end as coordinate $ M $.
Initially, meat $ i $ is placed at position $ S_i $. This means that meat $ i $ covers the interval from coordinate $ S_i $ to coordinate $ S_i + L_i $. A-san decided to remove some pieces of meat before lighting the charcoal under the grill net.
When grilling the meat, any part covered by two or more pieces of meat will be undercooked. Also, obviously, the meat removed before grilling cannot be eaten.
Find the maximum sum of the lengths of the parts that can be eaten without being undercooked when the meat to be removed is chosen optimally. In other words, this is the same as the sum of the lengths of the intervals on the grill net covered by exactly one piece of meat.
Input Format
The input is given from the standard input in the following format:
$ N $ $ M $ $ S_1 $ $ L_1 $ $ S_2 $ $ L_2 $ : $ S_N $ $ L_N $
- The first line contains two integers $N\ (1\ ≦\ N\ ≦\ 10^5),\ M\ (1\ ≦\ M\ ≦\ 10^5)$ separated by a space. This indicates that there are $ N $ pieces of meat and the length of the grill net is $ M $.
- The next $ N $ lines contain the information about the meat. The $i\ (1\ ≦\ i\ ≦\ N)$th line contains two integers $S_i,\ L_i\ (0\ ≦\ S_i\ <\ S_i+L_i\ ≦\ M)$ separated by a space. This indicates that initially, meat $ i $ is placed at coordinate $ S_i $ and the length of meat $ i $ is $ L_i $.
Output Format
Output the maximum sum of the lengths of the parts that can be eaten without being undercooked in one line. End the output with a newline.
Sample Input and Output
Sample Input #1
3 7
0 4
3 4
1 5
Sample Output #1
6
Sample Input #2
8 13
7 2
7 2
1 4
2 5
4 2
11 1
10 1
10 2
Sample Output #2
9
Notes/Hints
Sample Explanation 1
The figure below shows the initial arrangement of the meat and the state after removing meat $ 3 $ and grilling. The parts enclosed by the green frame are the parts that can be eaten without being undercooked. 
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分