#include using namespace std; int main(void){ int n, k; cin >> n >> k; vector ct(n); int a; for (int i = 0; i < n; i++) { cin >> a; ct[a-1]++; } int sum = 0, ans = 0; for (int i = 0; i < n; i++) { sum += ct[i]; if (ct[i] != 0) ans++; if (sum >= k) { break; } } cout << ans << endl; }