cswork / OAOpen practice workspace

IBMOA #25

Find Missing Integer

Estimated MediumJudge-ready

Topics (AI-labelled)Binary SearchIn-place Arrays

Find the k-th smallest positive integer that does not appear in the array; duplicates do not take up extra positions.

Input

The first line contains n k, and the second line contains the array. 1≤n≤200000, 1≤element≤10^9, 1≤k≤10^12.

Output

Output one integer, the answer.

Example 1

Input:

5 5
1 4 7 3 4

Output:

9

Example 2

Input:

2 1
1 1

Output:

2

Example 3

Input:

1 2
9

Output:

2

Example notes

The examples give 9, 2 and 2 respectively.

Editorial

Loading solution…