Олимпиадный тренинг

Задача 38123. Acowdemia I


Besi is studying for a PhD in Computer Science. She published N articles (1≤N≤105) and her i-th article was cited ci times (0≤ci≤ 105).

Besi heard that academic achievement is measured by the h-index. h-index is the largest number h such that the scientist has at least h articles, each of which is cited at least h times. For example, a scientist with four papers with citation counts (1,100,2,3) has an h-index of 2, and a scientist with citation counts of (1,100,3,3) has an h-index of 3.

To improve her h-index, Besi plans to write a review article citing some of her past articles. Due to a page limit, she can include no more than L citations in her review (0≤L≤105), so of course she can cite each of her articles no more than once.

Help Besi determine the maximum h-index she can achieve by writing her review article.

Note that the supervisor should have warned Besi that writing an article solely for the purpose of increasing his h-index is ethically dubious.

INPUT FORMAT
The first input line contains N and L.

The second input line contains N space-separated integers c1,…,cN.

OUTPUT FORMAT
The maximum h-index that Besi can get by writing a review article.
# Input Output Explanation
1 4 0
1 100 2 3 
2 Besi cannot cite his articles. As stated earlier, its h-index for (1,100,2,3) is 2.
2 4 1
1 100 2 3
3 If Besi cites the third article, her citation counts will become (1,100,3,3). As noted earlier, h in this case is 3.