#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, day, ans = 0x3f3f3f3f, cot, cnt;
struct rec {
  int dis, cost;
  bool operator<(const rec &b) const {
    return cost == b.cost ? dis < b.dis : cost > b.cost;
  }
} a[N], b[N];
long long m, sum;
set<rec> s1, s2;
void init() {
  scanf("%d%d", &n, &day);
  cin >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].cost), a[i].dis = i;
    if (i != n) s1.insert(a[i]);
  }
}
void judge() {
  for (int i = 1; i <= cnt; i++) s1.erase(s1.begin());
  int i = 1, minn = 0x3f3f3f3f;
  for (int i = 1; i <= cot; i++) minn = min(minn, b[i].dis);
  sum -= b[cot].cost;
  for (set<rec>::iterator it = s1.begin(); i <= day - cnt && it != s1.end();
       it++) {
    if (sum + (*it).cost <= m) {
      sum += (*it).cost, i++;
      minn = min(minn, (*it).dis);
    }
  }
  if (sum + a[1].cost > m) minn = 1;
  cout << minn << endl;
  exit(0);
}
void dawn() {
  int minn = 0x3f3f3f3f;
  set<rec>::iterator it = s1.begin();
  sum = 0;
  for (cnt = 1; cnt <= day; cnt++, it++) {
    sum += (*it).cost;
    b[++cot] = *it;
    if (sum > m) break;
  }
  if (sum <= m) {
    printf("%d\n", n);
    return;
  }
  if (cnt < day) judge();
  for (int i = 1; i <= cot; i++)
    ans = min(ans, b[i].dis), minn = min(minn, b[i].cost);
  for (int i = 1; i <= ans - 1; i++)
    if (sum + a[i].cost - minn > m) {
      ans = i;
      break;
    }
  cout << ans << endl;
}
int main() {
  init();
  dawn();
}
