A - 登山道の気温変化 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 233

問題文

高橋君は山頂を目指して登山道を歩いています。

登山道には 1 から N までの番号がついた N 個のチェックポイントがあり、チェックポイント i の気温は T_i 度です。

高橋君はチェックポイント 1 から出発し、2, 3, \dots, N の順にすべてのチェックポイントを通過して山頂(チェックポイント N)に到達します。

チェックポイント i2 \le i \le N)において、直前のチェックポイントとの気温差の絶対値が基準値 K 以上であるとき、すなわち |T_i - T_{i-1}| \geq K であるとき、チェックポイント i急変 が起きるといいます。

チェックポイント 2, 3, \dots, N のうち、急変が起きるチェックポイントの個数を求めてください。

制約

  • 2 \leq N \leq 10^5
  • 1 \leq K \leq 10^9
  • -10^9 \leq T_i \leq 10^9
  • 入力はすべて整数である

入力

N K
T_1
T_2
\vdots
T_N
  • 1 行目には、チェックポイントの数 N と、急変の基準値 K がスペース区切りで与えられる。
  • 続く N 行には、チェックポイントの気温が順に与えられる。このうち i 番目の行(1 \le i \le N)には、チェックポイント i の気温 T_i が与えられる。

出力

急変が起きるチェックポイントの個数を 1 行で出力してください。


入力例 1

5 3
10
12
15
14
20

出力例 1

2

入力例 2

4 10
5
8
3
12

出力例 2

0

入力例 3

10 5
0
-4
2
7
1
10
6
-1
4
4

出力例 3

6

入力例 4

20 100
0
50
-60
40
140
139
239
100
0
-100
-50
49
149
300
201
101
1
-98
-198
-97

出力例 4

13

入力例 5

2 1000000000
-1000000000
0

出力例 5

1

Score : 233 pts

Problem Statement

Takahashi is walking along a mountain trail aiming for the summit.

There are N checkpoints numbered from 1 to N along the trail, and the temperature at checkpoint i is T_i degrees.

Takahashi starts from checkpoint 1 and passes through all checkpoints in the order 2, 3, \dots, N to reach the summit (checkpoint N).

At checkpoint i (2 \le i \le N), if the absolute difference in temperature from the previous checkpoint is at least the threshold value K, that is, if |T_i - T_{i-1}| \geq K, we say a sudden change occurs at checkpoint i.

Among checkpoints 2, 3, \dots, N, find the number of checkpoints where a sudden change occurs.

Constraints

  • 2 \leq N \leq 10^5
  • 1 \leq K \leq 10^9
  • -10^9 \leq T_i \leq 10^9
  • All inputs are integers

Input

N K
T_1
T_2
\vdots
T_N
  • The first line contains the number of checkpoints N and the threshold value for sudden changes K, separated by a space.
  • The following N lines give the temperatures at the checkpoints in order. The i-th of these lines (1 \le i \le N) gives the temperature T_i at checkpoint i.

Output

Print the number of checkpoints where a sudden change occurs, in a single line.


Sample Input 1

5 3
10
12
15
14
20

Sample Output 1

2

Sample Input 2

4 10
5
8
3
12

Sample Output 2

0

Sample Input 3

10 5
0
-4
2
7
1
10
6
-1
4
4

Sample Output 3

6

Sample Input 4

20 100
0
50
-60
40
140
139
239
100
0
-100
-50
49
149
300
201
101
1
-98
-198
-97

Sample Output 4

13

Sample Input 5

2 1000000000
-1000000000
0

Sample Output 5

1