A conveyor belt carries labeled candies; the i-th candy has integer flavor a[i]. Count how many contiguous stretches of the belt contain exactly k distinct flavors.
Formally, count the pairs (i, j) with 0 ≤ i ≤ j < n such that the number of distinct values among a[i..j] equals k.
Input format
Line 1: two integers n and k separated by a space.
Line 2: n space-separated integers, the flavors.
Output format
A single integer: the number of contiguous subarrays containing exactly k distinct values. Output 0 if none exist.
Constraints
- 1 ≤ n ≤ 100000
- 1 ≤ k ≤ n
- 1 ≤ each flavor ≤ 1000000000
The count fits in a 64-bit signed integer.