cho.sh
Notes
Loading...

Solving Problems

Time limit

2s

Memory limit

128 MB

Problem

Yujin solves problems numbered from 1 to N. She must solve problem 1 first. After solving problem A, she may either solve problem A+1, or skip problem A+1 and solve problem A+2. For example, solving problems in the order 1, 3, 4, 6 is possible, but solving them in the order 1, 3, 5, 8 is not possible.

For each problem i, P_i is the interest value Yujin feels when solving it. As soon as the difference between the maximum and minimum interest values among the problems she has solved so far is at least V, her teacher makes her stop solving problems. If no possible solving order ever reaches such a moment, Yujin solves all N problems.

Find the minimum number of problems Yujin must solve before she is stopped.

Input

The first line contains the number of problems N and the integer V. N is a positive integer not greater than 50, and V is a positive integer not greater than 1,000.

The second line contains P_1, P_2, ..., P_N. P_i is the interest value Yujin feels when solving problem i, and each value is an integer between 0 and 1,000 inclusive.

Output

Print the minimum number of problems she must solve until the condition is first satisfied. If the condition cannot be satisfied, print N.