n, k = map(int, input().split()) p = sorted(list(map(int, input().split())), reverse=True) if n == k: print(n) exit() fail = p[k] ans = k - p[:k].count(fail) print(ans)