AlgoUniversity
  • Go Back
Discussion
Shweta And Candies :

Author

Akshay Sharma

Difficulty Level : Medium

Submissions : 308

Asked In : Palo-Alto-Networks

Marks :100

: 5 | : 2

Shweta is a college girl and she loves candies she wants to share some candies with her friend Radhika. She is having N candies such that the ith candy is of A[i] brand were ($$$0 \le i \le N$$$). Lets us call this array the brand array. She wants to share the K candies with Radhika Such that the K-sized subsequence of the candies has a minimum number of distinct brands among all the possible subsequences of the length K.

Formally you will have to help Shweta in determining the subsequence of length K in the given array which has the minimum number of distinct brands among all possible subsequences of length K.

You will have to print the total brands of candies Radhika received.

Input

The First line of input contains two integers N and K the number of candies Shweta has and the number of candies that she wants to give to her friend Radhika. ($$$1 \le K \le N \le 10^5$$$).

The next line contains N-spaced integers that each A[i] represents the brand of ith candy ($$$1 \le A_i \le 10^8$$$).

Output

For each test case print, a single integer of the number of candies Radhika will receive

Examples

Input
10 6 
1 3 2 4 3 4 5 3 4 3
Output
2
Input
4 3
1 1 1 3
Output
1

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.