(RankList for this Question)
Here's the deal: in this contest, if a contestant scores as much as or higher than the person in the k-th spot, they move on to the next round. Of course, their score must be positive. We've got n participants in the mix (n ≥ k), and you've got their scores. Can you figure out how many of them are making it to the next round?
Constraints
Constraints are provided in the Input format
Input Format
The first line consists of two integers, n and k (where 1 ≤ k ≤ n ≤ 50), separated by a single space.
The second line contains n space-separated integers: a1, a2, ..., an (where 0 ≤ ai ≤ 100), representing the scores of participants ranked from first to last. The sequence is non-increasing, meaning each score is greater than or equal to the subsequent score in the sequence.
Output Format
Output the number of participants who advance to the next round.
Example 1
Input:
8 5
10 9 8 7 7 7 5 5
Output:
6
Explanation:
In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.
Example 2
Input:
4 2
0 0 0 0
Output:
0
Explanation:
In the second example nobody got a positive score.
Log In to solve the Question