cswork / OAOpen practice workspace

SnowflakeOA #12

Unequal Elements (Also for Core/Database Intern :)

Estimated MediumJudge-ready

Topics (AI-labelled)SubsequencesHashing

Choose a subsequence of the skill array in which the number of adjacent elements with different values is at most k, and find its maximum length. The subsequence does not need to be contiguous.

Input

The first line contains n k, and the second line contains n skill values. The original text gives n≤2000 and the remaining constraints are truncated; this site specifies 1≤n≤2000, 0≤k<n, and 1≤skill value≤10⁹.

Output

Output the single integer required by the problem.

Example 1

Input:

6 2
1 1 2 3 2 1

Output:

5

Example 2

Input:

5 0
1 2 1 2 1

Output:

3

Example 3

Input:

1 0
1

Output:

1

Example notes

The answers to the three public examples are, in order: 5; 3; 1. All examples have been verified by independent small-scale enumeration or state search.

Editorial

Loading solution…