n,k=map(int,input().split()) P=list(map(int,input().split())) import bisect P.append(10000) P.sort() ans=0 for x in P: a=n-bisect.bisect_right(P,x) if k>=a: ans=max(ans,a) print(ans)