Subin and the Melting Candy

Starting at the origin and moving only right or up, visit baskets over time to maximize total candies collected, where a basket's candies shrink by one per time unit.

Medium7Dynamic programmingSortingInterviewNo attempts yetTime limit1sMemory limit64 MB

Problem

Subin is sitting on the coordinate plane. "I love the coordinate plane so much!!" said Subin. The plane has NN candy baskets, and each basket holds MM candies. The baskets are at (x1,y1),(x2,y2),,(xN,yN)(x_1, y_1), (x_2, y_2), \dots, (x_N, y_N), and Subin starts at (0,0)(0, 0).

The weather is hot today. Each time 11 unit of time passes, one candy melts away from every basket that still has candy left. After tt units of time have passed, a basket holds max(0,Mt)\max(0, M - t) candies.

Subin is very hungry, so when he reaches a basket he eats all the candies in it instantly. Eating takes no time. When Subin moves a distance of 11, 11 unit of time passes. Subin can move only up (the direction in which the yy coordinate increases) or right (the direction in which the xx coordinate increases).

Write a program that finds the maximum number of candies Subin can eat.

Input

The first line contains NN and MM.

Each of the next NN lines contains the position xix_i, yiy_i of one candy basket. (0N3000 \le N \le 300, 1M1061 \le M \le 10^6, 0xi,yi3000 \le x_i, y_i \le 300)

No two candy baskets share a position, and there is no candy basket at (0,0)(0, 0).

Output

Print the maximum number of candies Subin can eat.