You can get a good reference from the following program
# The following command can take n number of inputs
n,k=map(int, input().split(' '))
a=list(map(int,input().split(' ')))
count=0
for each in a:
if each >= a[k-1] and each !=0:
count+=1
print(count)