cswork / OAOpen practice workspace

AmazonOA #363

Count Spikes

Estimated HardJudge-ready

Topics (AI-labelled)Stacks & HeapsBinary Search

prices[i] is called a k-Spike if at least k elements to its left are strictly less than prices[i], and at least k elements to its right are strictly less as well. Given the array prices and an integer k, count the number of k-Spike elements.

Input

The first line contains n and k; the second line contains n integers prices[i]. Constraints: 1≤n≤100000, 1≤k≤n, 1≤prices[i]≤1000000000.

Output

Output the number of k-Spike elements.

Example 1

Input:

6 2
1 2 8 5 3 4

Output:

2

Example 2

Input:

5 1
1 2 2 1 2

Output:

2

Example 3

Input:

5 1
7 7 7 7 7

Output:

0

Example notes

The answer for the example is 2: the values 8 and 5 both satisfy the condition.

Editorial

Loading solution…