Under construction

Still being built. Things may change

Longest Even Contiguous Subsequence (small)

Interview

Time limit1sMemory limit1024 MB

Summary
Delete at most K elements from a sequence, then report the longest contiguous run of even numbers possible.
Level

Medium5 of 10

Topics
Sliding window, Two pointers, Array, Greedy
Solved
No attempts yet

Problem

There is a sequence SS of length NN. Every element of SS is a positive integer.

You may pick an element at any position in SS and delete it, at most KK times in total.

For example, suppose SS is given as follows.

S : 1 2 3 4 5 6 7 8

If you delete the 4th element, 4, the sequence becomes the following.

S : 1 2 3 5 6 7 8 

Given a sequence obtained by deleting at most KK elements from SS, find the maximum length of a contiguous subsequence consisting only of even numbers.

Input

The first line contains the length NN of the sequence SS and the maximum number of deletions KK, separated by a space.

The second line contains the NN integers that make up SS, separated by spaces.

Output

Print the maximum length of a contiguous subsequence consisting only of even numbers in a sequence obtained by deleting at most KK elements from SS.

Constraints

  • 1≤N≤50,0001 \le N \le 50,000
  • 1≤K≤1001 \le K \le 100
  • 1≤1 \le element value ≤106\le 10^6

Examples1

  1. Example 1

    Input
    8 2
    1 2 3 4 5 6 7 8
    
    Expected output
    3