DAY-1

3.8

107 votes
Very-Easy
Problem

Joe has recently got his new collection of sci-fi novels. He arranges all books in a shelf. Because of his crazy rules, he only reads book from one of the ends of the shelf. Thus, each book Joe reads is either leftmost or rightmost book from the shelf.

Joe cannot read a book if it has more than K chapters, again a crazy rule.

When Joe has read a book, he removes it from the shelf. Joe stops when he is unable to read any book from any end of the shelf.

How many books are still present in the shelf?

Input:

The first line of the input contains two integers N, the total number of books and K, the maximum number of chapters in a book which Joe can read.

The next  N lines denote the number of chapters in the ith book. 

Output:

Print the number of books left in the shelf, when Joe stops reading.

 

Constraints:

1<=N<=105

1<=K<=109

1<=chaptersinanybook<=109

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Joe can read books in the following order: [4,3,4,2,5,1,6 4]→[3,4,2,5,1,6 4]→[3,4,2,5,1,6]→[4,2,5,1,6]→[2,5,1,6]→[5,1,6]

So the number of books left in the shelf will be 3.

Editor Image

?