fb pixel

Becoming an influencer

You’ve been posting a lot of content on social media throughout the last several months. Now you’d like to analyze your most popular period. You’d like to know the maximum amount of views your content got during a period that doesn’t exceed a time interval of length t.

Input

The first line of the input contains two integers n (1 ≤ n ≤ ) - the number of content pieces posted and t (1 ≤ t ≤ ) - the maximum time interval you’d like to consider.
The next n lines contain space-separated integers - the time posted and the views obtained from the post (1 ≤ ).

Output

The program should print the maximum sum of views that are within a time period not exceeding t.

Examples

Input
Output
4 5 10 1000 12 1500 6 2000 1 1100
3100

Explanation

The last two - posted at times 1 and 6 would result in 2000 + 1100 views.
 
To check your solution you need to sign in
Sign in to continue