#yuki1380 n,k=map(int,input().split()) 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)