N,K = map(int,input().split()) p = list(map(int,input().split())) p.sort() p.reverse() now = K-1 while now >= 0 and p[now+1] == p[now]: now -= 1 print (now + 1)