Rabbit Carrot
문제
Rabbit called Carrot is willing to cross the bridge. The bridge consists of poles of different height. Carrot can jump at most centimeters up and any distance down.
[이미지 1]
The rabbit starts crossing the bridge from the left and is standing at height zero immediately before the first pole. The goal of the Carrot is to reach the other side of the bridge by jumping on each pole in order.
However, it might happen, that the rabbit will not be able to jump on some poles as it will be too high.
Help the rabbit Carrot to cross the bridge by modifying the heights of some poles. Calculate the smallest possible amount of poles the height of which has to be either increased or decreased so that the Carrot could cross the bridge. Height of each of the poles can be increased by any amount and decreased to a non-negative value.
입력
The first line contains two integers: the number of bridge poles and the Carrot leap-up size . The following lines contain the heights of the poles given as integers one number per line.
출력
Output one integer – the least number of poles that have to be either lifted or lowered so that the rabbit Carrot could cross the bridge.
예제
예제 1
5 400 300 700 200 1000 500
1
예제 2
3 300 700 1000 1300
3