speakers

Problem Description

Peanut is organising a talk today with a group of N people. The stage is M meters wide and the N people are seated in a line, each of them Di meters from the leftmost edge of the stage. Peanut wants to place some speakers along the line so that everyone can hear his speech. However, some people have hearing loss. Thus, each person i requires them to be at most Ri away from a speaker. Help Peanut determine what is the minimum number of speakers he needs to place such that everyone can hear his speech.

Limits

Subtask 1 (14%): 1 ≤ N, M ≤ 15.
Subtask 2 (16%): 1 ≤ N, M ≤ 1 000.
Subtask 3 (21%): 1 ≤ N, M ≤ 100 000.
Subtask 4 (49%): 1 ≤ N ≤ 100 000. 1 ≤ M ≤ 1 000 000 000.
Subtask 5 (0%): Sample testcase.

Input

The first line of input contains two integers, N and M.
The next N lines of input contains two integers each, Di and Ri.

Output

The output should contain one integer, the minimum number of speakers required such that everyone can hear his speech.

Sample Input 1

3 3
0 1
1 1
2 1

Sample Output 1

1

Sample Input 2

4 6
0 2
3 1
4 1
5 2

Sample Output 2

2

Submitting .cpp to 'speakers'


You're not logged in! Click here to login


Compile Errors


							
Time Limit: 1 Seconds
Memory Limit: 1024MB
No. of ACs: 90
Your best score: 0
Source: Dunjudge Archive
Editorial: 1

Subtask Score
1 14
2 16
3 21
4 49
5 0