1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <bits/stdc++.h>

int main()
{
	std::ios_base::sync_with_stdio(0);
	
	int n;
	int k;

	std::cin >> n >> k;

	std::vector<int> v(n, 0);

	for(int i=0; i<n; i++)
	{
		std::cin >> v[i];
	}

	std::sort(v.begin(), v.end(), std::greater<>());
	auto it = std::upper_bound(std::begin(v), std::end(v), v[k-1], std::greater<>{});

	std::cout << std::distance(v.begin(), it) << "\n";
		
	return 0;
}