# coding:UTF-8
import sys

MOD = 10 ** 9 + 7
INF = float('inf')

N, K = list(map(int, input().split()))     # スペース区切り連続数字
P = list(map(int, input().split()))     # スペース区切り連続数字

P.sort(reverse=True)
B = P[K-1]

c = 0
for i in range(N):
    if P[i] >= B:
        c += 1

if c > K:
    B += 1
    c = 0
    for i in range(N):
        if P[i] >= B:
            c += 1

print(c)