Chinmay and his work ids

3

1 votes
Easy
Problem

Chinmay has a lot of work to do.Each work is associated with some id's which further contains tasks. Given an array of items, an i-th index element denotes the item id’s . Chinmay has only 'm' amount of time remaining.In each unit of time he can complete one task of a particular id. Due to his poor mind he is unable to solve the problem. Help Chinmay in removing m elements such that there should be minimum distinct id’s left.Print the number of distinct id’s.

Input
The three lines of the input, the first line contains N, denoting number of elements in an array,second line contains N elements/ids, and third line contains the number M.
Output
For each test case, print the minimum number of distinct ids.
Constraints
1 ≤ N ≤ 105
1 ≤ arr[i] ≤ 106
1 ≤ M ≤ 105

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In the first example input as m=3 so we can remove 3 elements.On removing 2,1,2 only 1 distinct id 3 is left.So answer will be 1 in this case.

Editor Image

?