A gelato truck logs the flavor ID (a positive integer) of every scoop it sells during the day, in order, as an array of n integers. Given a limit K, find the length of the longest contiguous window of sales that contains at most K distinct flavor IDs.
Input format
Line 1: two integers n and K.
Line 2: n space-separated positive integers, the flavor IDs sold in order.
Output format
A single integer: the length of the longest contiguous subarray containing at most K distinct flavor IDs. If K is 0, the answer is 0.
Constraints
- 1 ≤ n ≤ 100000
- 0 ≤ K ≤ n
- 1 ≤ flavor ID ≤ 1000000000