Keenan recently bought a new game, and he wants to show it to you!
Keenan's game consists of cells in a row, of varying height. Keenan also has many water buckets, and he wants to fill every cell with water.
However, as Keenan explains, water mechanics in this game are a bit weird. There is an integer chosen by the game, where water can flow at most units on equal-height cells. Specifically, if Keenan pours his bucket into a cell , the water can flow in both directions, filling all cells until cells and with water before it loses momentum. However, if the water descends from a higher elevation to a lower one, this limit is reset to , and the water can continue flowing as if it had just been poured into the lower cell. Water can never flow from a lower elevation to a higher one.
Keenan wants to fill all his cells with water, but he doesn't want to use that many buckets. Can you tell him the minimum number of cells he has to pour his bucket into so that all cells are filled with water?
Constraints
Subtask 1 [30%]
Subtask 2 [70%]
No additional constraints.
Input Specification
The first line will contain two space-separated integers, and .
The next line will contain space-separated integers, , the heights of the cells, in order.
Output Specification
Output the minimum number of cells Keenan has to pour into in order to fill the entire row of cells with water.
Sample Input
6 1
3 3 3 4 4 7
Sample Output
2
Explanation
If we pour into the second and sixth cells, we can fill all the cells in moves, which we can prove to be minimal.
Note that if we pour water into the third cell, it would not reach the first cell.
Comments