Broadcast Tower

Time limit2sMemory limit512 MB

Summary
Place a tower of height H in a row of buildings; a building west of it receives its signal if no taller building blocks the path. Maximize receivers.
Level

Medium5 of 10

Topics
Stack, Array
Solved
No attempts yet

Problem

City X has NN buildings standing in one row from west to east. The westmost building is number 1 and the eastmost is number NN. The heights are integers h1,h2,…,hNh_1, h_2, \dots, h_N, and no two buildings have the same height. The city government plans to build one broadcast tower in the same row. The tower can stand west of building 1, between two neighbouring buildings, or east of building NN. Its height is HH, and HH differs from every building height.

Because of an unusual design, the tower sends signals only to the west. A signal is a horizontal ray that travels parallel to the ground, and rays leave the whole body of the tower, from the top down to the bottom. The tower therefore emits a continuous band of rays whose width equals the height of the tower. A ray stops where it hits a building. Each building has a receiver on its roof, and a building receives the message if at least one ray reaches that receiver.

In other words, building ii receives the message exactly when all three conditions hold: building ii stands west of the tower, hih_i is not greater than the height of the tower, and no building jj with j>ij > i standing between building ii and the tower is higher than building ii.

In the figure above the buildings that receive the message are 2, 5, 6, and 9.

You are given the heights of the buildings and the height of the tower. Write a program that places the tower where the largest number of buildings receives the message, and prints that number.

Input

The first line contains the number of buildings NN and the height of the tower HH, separated by a space.

The second line contains the heights of the NN buildings, separated by spaces, in order from building 1 to building NN.

Output

Print on one line the largest number of buildings that receive the message when the tower is placed in the best position.

Constraints

  • 1≤N≤10000001 \le N \le 1000000
  • 1≤hi≤1091 \le h_i \le 10^9, 1≤H≤1091 \le H \le 10^9
  • The building heights are pairwise different, and HH equals none of the hih_i

Explanation

In the first example the best position for the tower is between building 8 and building 9. Buildings 2, 5, 6, 7, and 8 receive the message.

Examples4

  1. Example 1

    Input
    12 180
    200 170 130 90 150 140 40 30 100 160 50 110
    
    Expected output
    5
    
  2. Example 2

    Input
    1 10
    3
    
    Expected output
    1
    
  3. Example 3

    Input
    1 5
    7
    
    Expected output
    0
    
  4. Example 4

    Input
    5 100
    1 2 3 4 5
    
    Expected output
    1