Under construction

Still being built. Things may change

Financial Report

Time limit2sMemory limit512 MB

Summary
Choose days that include the last day N, with consecutive picks at most D days apart, to maximize how many chosen days set a new record-high sales amount.
Level

Medium6 of 10

Topics
Dynamic programming, Segment tree
Solved
No attempts yet

Problem

JOI mart is a shop with N days of history. After it opened, the sales amount on the i-th day (1 ≤ i ≤ N) was AiA_i yen.

Bitaro is the shop manager of JOI mart. He will make a presentation of the financial report. He chooses some days and shows a bar chart of their sales amounts in chronological order, then explains how the sales changed over those days. He wants the presentation to leave a strong impression, so he picks the data carefully.

Suppose he chooses the sales data for mm days (1 ≤ m ≤ N), namely days p1,p2,…,pmp_1, p_2, \ldots, p_m after opening, where 1≤p1<p2<⋯<pm≤N1 \le p_1 < p_2 < \cdots < p_m \le N. The impression score of the bar chart is the number of indices jj (1 ≤ j ≤ m) such that j=1j = 1 or max⁡{Ap1,Ap2,…,Apj−1}<Apj\max\{A_{p_1}, A_{p_2}, \ldots, A_{p_{j-1}}\} < A_{p_j}. In other words, it counts how many chosen days set a new record-high sales amount.

Bitaro must satisfy both conditions:

  • He shows the latest sales amount, so pm=Np_m = N.
  • For consecutive chosen days, the gap is at most D days. If m≥2m \ge 2, then pj+1−pj≤Dp_{j+1} - p_j \le D for every 1≤j≤m−11 \le j \le m-1.

Given the sales data and D, find the maximum impression score over all valid choices.

Input

Read the following data from standard input. All values are integers.

N D
A_1 A_2 ... A_N

Output

Write one line to standard output containing the maximum impression score.

Constraints

  • 1 ≤ N ≤ 300000.
  • 1 ≤ D ≤ N.
  • 0 ≤ AiA_i ≤ 1000000000 (1 ≤ i ≤ N).

Examples3

  1. Example 1

    Input
    7 1
    100 600 600 200 300 500 500
    
    Expected output
    3
    
  2. Example 2

    Input
    6 6
    100 500 200 400 600 300
    
    Expected output
    4
    
  3. Example 3

    Input
    11 2
    1 4 4 2 2 4 9 5 7 0 3
    
    Expected output
    4