N,K=map(int,input().split()) p=list(map(int,input().split())) p_set=sorted(list(set(p)))[::-1] p_new={} for i in p_set: p_new[i]=p.count(i) num=0 i=0 while num+p_new[p_set[i]]<=K: num+=p_new[p_set[i]] i+=1 print(num)