def main(): N, K = map(int, input().split()) scores = list(map(int, input().split())) scores.sort(reverse=True) if K == N: print(N) return if scores[K-1] > scores[K]: print(K) return print(scores.index(scores[K-1])) if __name__ == "__main__": main()