#include <bits/stdc++.h>
using namespace std;
struct Person {
  int val;
  int index;
  Person() {
    val = -1;
    index = -1;
  }
  Person(int a, int b) : val(a), index(b) {}
};
struct CompareHeight {
  bool operator()(Person const& p1, Person const& p2) {
    if (p1.val == p2.val) return p2.index > p1.index;
    return p1.val > p2.val;
  }
};
int main() {
  priority_queue<Person, vector<Person>, CompareHeight> Q;
  int n, k;
  cin >> n >> k;
  int k2 = k;
  long long tot;
  cin >> tot;
  Person arr[n];
  for (int i = 0; i < n; ++i) {
    long long temp;
    cin >> temp;
    arr[i] = Person(temp, i);
  }
  int ptr = n - 2;
  long long s = 0;
  while (k > 0) {
    Q.push(arr[ptr]);
    s += arr[ptr].val;
    ptr--;
    k--;
  }
  int ans = n - 1;
  for (int i = n - k2 - 1; i > 0; i--) {
    if (s > tot) {
      ans = min(ans, i);
    }
    s -= Q.top().val;
    Q.pop();
    s += arr[i - 1].val;
    Q.push(arr[i - 1]);
  }
  if (s > tot) {
    ans = min(ans, 0);
  }
  cout << ans + 1 << "\n";
  return 0;
}
