K-Distinct Subarrays


Given an array aa of nn integers, count how many non-empty contiguous subarrays contain at least kk distinct values.

Input

The first line contains two integers nn and kk.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n.

Output

Print a single integer: the number of non-empty contiguous subarrays that contain at least kk distinct values.

Constraints

  • 1kn21051 \le k \le n \le 2 \cdot 10^5
  • 109ai109-10^9 \le a_i \le 10^9

Example 1

Input 1
5 3
1 2 1 3 2
Output 1
5
Explanation

The subarrays with at least 33 distinct values are:

  • [1,2,1,3][1, 2, 1, 3]
  • [1,2,1,3,2][1, 2, 1, 3, 2]
  • [2,1,3][2, 1, 3]
  • [2,1,3,2][2, 1, 3, 2]
  • [1,3,2][1, 3, 2]

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.