665. Subarrays with K different Integers

0

Hard

Kartik is a bright student who loves solving hard coding problems. He wants to find out the total number of **Good** subarrays :
**A good array is an array where the number of different integers in that array is exactly k**.
You have to help Kartik to solve the problem.
You are given an integer array **Nums** and an integer **k**, print the number of good subarrays of nums.

Input Format

First Line contains a single Integer **N** (Size of array) and **K**.

Second Line consisting of an Array.

Second Line consisting of an Array.

Output Format

Print the total number of good subarrays.

Example

Input

5 2
1 2 1 2 3

Output

7

Constraints

1 <= N <= 2*10

1 <= Nums[i] , K <= N

^{4}1 <= Nums[i] , K <= N

Loading...

View Submissions

Console