#include <bits/stdc++.h>
using namespace std;
const int max_n = 100010;
const int max_k = 100010;
int n, k;
long long b;
long long A[max_n];
int res;
long long hp[max_k];
int hpsz = 0;
long long hpsum = 0;
void inithp() {
  for (int i = 0; i < k - 1; ++i) hp[i] = 0;
  hpsz = k - 1;
  hpsum = 0;
}
void updatehp(long long val) {
  if (k > 1 and hp[0] < val) {
    hpsum -= hp[0];
    pop_heap(hp, hp + hpsz, greater<long long>());
    --hpsz;
    hp[hpsz] = val;
    ++hpsz;
    push_heap(hp, hp + hpsz, greater<long long>());
    hpsum += val;
  }
}
int main() {
  int tmp;
  scanf("%d %d", &n, &k);
  cin >> b;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &tmp);
    A[i] = (long long)(tmp);
  }
  res = n - 1;
  inithp();
  for (int i = n - 2; i >= 0; --i) {
    if (hpsum + A[i] > b) res = i;
    updatehp(A[i]);
  }
  printf("%d\n", res + 1);
  return 0;
}
