This page is still under construction.

Parts of this page are still being built. What you see may change.

Viewing Terraces

Time limit1sMemory limit128 MB

Summary
In a chain of terraces where climbing up costs height difference and descending is free, find the most distinct terraces reachable on k credits without returning to ground.
Level

Medium5 of 10

Topics
Sliding window, Two pointers, Array
Solved
No attempts yet

Problem

In the mountains stand viewing terraces connected by elevators. Going up from a lower terrace to the adjacent, higher terrace costs as many credits as the difference between the two terraces' heights. Going down from a higher terrace to a lower one is free. The terraces form a single chain: from the first terrace you can reach only the second, from the second only the first and the third, and so on.

A tourist holds only kk credits. Find the largest number of distinct terraces the tourist can visit in one continuous trip, without ever coming back down to the ground in between. Stepping onto the terrace where the trip begins costs nothing.

Input

The first line contains two integers nn and kk, separated by a single space (1≤n≤200001 \le n \le 20000, 0≤k≤200000 \le k \le 20000). Here nn is the number of terraces and kk is the number of credits the tourist has.

Each of the next nn lines contains the height of one terrace, h1,h2,…,hnh_1, h_2, \dots, h_n, one per line. Every height satisfies 1≤hi≤100001 \le h_i \le 10000.

Output

Print a single integer: the largest number of terraces the tourist can visit with kk credits.

Examples1

  1. Example 1

    Input
    5 1
    4
    2
    1
    2
    4
    
    Expected output
    4