cswork / OAOpen practice workspace

IBMOA #22

Find Max Distinct Items

Estimated MediumJudge-ready

Topics (AI-labelled)GreedyHashing

A store sells items numbered 1 to n, and item i costs i. You already own the items in arr; find the total number of distinct items you own after buying within budget k. Items you already own count even if they are outside the store's range, and duplicate numbers count only once.

Input

The first line contains n m k, and the second line contains the m numbers of owned items. 1≤n≤10^6, 1≤m≤10^5, 1≤k≤10^9, 1≤arr[i]≤10^6.

Output

Output one integer, the answer.

Example 1

Input:

5 2 8
3 6

Output:

5

Example 2

Input:

3 2 2
1 1

Output:

2

Example 3

Input:

2 1 1
6

Output:

2

Example notes

The examples give 5, 2 and 2 respectively. In the first example the owned item 6 still counts, and 1, 2 and 4 are newly bought.

Editorial

Loading solution…