N, K = [int(x) for x in input().split()] results = [int(x) for x in input().split()] passer = [] for b in range(1, 10000): counter = 0 for x in results: if x >= b: counter += 1 passer.append(counter) # print(passer) passer = [x for x in passer if x <= K] # print(passer) if not passer: print(0) # elif set(passer) == {0}: # print(K) else: print(max(passer))