Nails
InterviewTime limit1sMemory limit128 MB
Lower at most k nails to match a chosen height and maximize how many nails share that height.
Problem
Adam is hammering nails into a board. He has already driven some of the nails to their own heights, but he has no time to keep working. Kozik, standing next to him, wants to drive a few more nails so that as many nails as possible end up at the same height.
Kozik can swing the hammer at most times. His strength and precision are so great that a single strike can drive any nail down to any height he likes between and the height at which that nail is currently driven. In other words, one strike lowers a chosen nail to any value from up to its current height.
Input
The first line contains two integers and , the number of nails and the maximum number of times Kozik may strike ().
The second line contains integers (), where is the height at which the -th nail is currently driven.
Output
Print a single line with the maximum number of nails that can be at the same height after Kozik finishes striking.
Hint
For example, if six nails are driven at heights and , Kozik can lower the two nails at heights and down to height , leaving five nails at height .