Next Round

题意翻译

# CF158 Next Round 下一轮 # 题意简述 有$n$个人参加一场比赛,其中分数排名前$k$位的人将被选入下一轮(选入下一轮的人分数必须为正,见样例#2),特别的,如果几个人分数相同且刚好并列处于第$k$名(或是并列$k-i$名,但是全部算入后选入下一轮的人数超过$k$人),这几个人都将被选入下一轮(见样例#1),题目要求你输出进入下一轮的人数。输入保证已经按分数从大到小排序。 # 输入输出格式 ## 输入格式 输入一共$2$行: 第$1$行是两个数$n,k$,分别代表参加比赛的人数和预计将会进入下一轮的人数; 第$2$行有$n$个数,分别参加比赛的人的分数 $a_1,a_2,...,a_n$ 。(输入保证 $a_i \geq a_{i+1}$) ## 输出格式 输出一个正整数,即实际进入下一轮的人数。 # 说明 在样例#1中,第五位和第六位参赛者都获得了七分,所以有六人进入下一轮。 在样例#2中,没有人得到大于0的评分。 翻译提供者:n0000000000o

题目描述

"Contestant who earns a score equal to or greater than the $ k $ -th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules. A total of $ n $ participants took part in the contest ( $ n>=k $ ), and you already know their scores. Calculate how many participants will advance to the next round.

输入输出格式

输入格式


The first line of the input contains two integers $ n $ and $ k $ ( $ 1<=k<=n<=50 $ ) separated by a single space. The second line contains $ n $ space-separated integers $ a_{1},a_{2},...,a_{n} $ ( $ 0<=a_{i}<=100 $ ), where $ a_{i} $ is the score earned by the participant who got the $ i $ -th place. The given sequence is non-increasing (that is, for all $ i $ from $ 1 $ to $ n-1 $ the following condition is fulfilled: $ a_{i}>=a_{i+1} $ ).

输出格式


Output the number of participants who advance to the next round.

输入输出样例

输入样例 #1

8 5
10 9 8 7 7 7 5 5

输出样例 #1

6

输入样例 #2

4 2
0 0 0 0

输出样例 #2

0

说明

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. In the second example nobody got a positive score.