A postman delivers letters to his neighbors in a one-dimensional world.
The post office, which contains all of the letters to begin with, is located at , and there are houses to which the postman needs to deliver the letters. House is located at position , and there are letters that need to be delivered to this location. But the postman can only carry letters at once.
The postman must start at the post office, pick up some number of letters less than or equal to his carrying capacity, and then travel to some of the houses dropping off letters. He must then return to the post office, repeating this process until all letters are delivered. At the end, he must return to the post office.
The postman can travel one unit of distance in one unit of time.
What is the minimum amount of time it will take the postman to start at the post office, deliver all the letters, and return to the post office?
Input
The first line of input contains two space-separated integers and .
Each of the next lines contains two space-separated integers and .
Output
Print, on a single line, the minimum amount of time it will take to complete the mail delivery route.
Sample Input 1
4 10
-7 5
-2 3
5 7
9 5
Sample Output 1
42
Sample Input 2
7 1
9400000 10000000
9500000 10000000
9600000 10000000
9700000 10000000
9800000 10000000
9900000 10000000
10000000 10000000
Sample Output 2
1358000000000000
Comments