#yuki1380 n,k=map(int,input().split()) if n==1: if k==1: print(1) else: print(0) exit() p=list(map(int,input().split())) s=sorted(p,reverse=True) res=k-1 while k>0: if s[k]!=s[k-1]: print(k) exit() else: k-=1 print(0)