import sys if sys.platform =='ios': import clipboard a=clipboard.get() a = a.split('\n') text = '\n'.join(a) with open('input_file.txt','w') as f: f.write(text) sys.stdin = open('input_file.txt') n,k = map(int,input().split()) P = sorted(list(map(int,input().split())))[::-1] A = [] for i in range(n): A.append(P[i]) if len(A) > k: while P[i] in A: A.remove(P[i]) break print(len(A))