Postman

Deliver m_i letters to house i at position x_i from the origin, carrying at most k letters per trip, and return to the origin each time; minimize total distance.

Medium6GreedySortingMathNo attempts yetTime limit1sMemory limit512 MB

Problem

A postman delivers letters to the houses of a one-dimensional world.

The post office holds every letter at the start and sits at coordinate x=0x = 0. There are nn houses that need mail. House ii sits at coordinate xix_i and needs mim_i letters. The postman carries at most kk letters at a time.

The postman starts at the post office, picks up any number of letters up to his carrying capacity, visits some of the houses and drops letters off, then returns to the post office. He repeats this until every letter is delivered, and he ends at the post office. The letters for one house may be carried over several trips.

The postman moves one unit of distance in one unit of time.

Find the minimum time the postman needs to start at the post office, deliver every letter, and return to the post office.

Input

The first line contains two space separated integers nn and kk. (1n10001 \le n \le 1000, 1k1071 \le k \le 10^7)

Each of the next nn lines contains two space separated integers xix_i and mim_i. (xi107|x_i| \le 10^7, 1mi1071 \le m_i \le 10^7)

Output

Print on a single line the minimum time needed to deliver every letter and return to the post office.