#include<bits/stdc++.h>
using namespace std;
#define MAXN	100005
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
struct info {int p, c, home; };
int n, k, ans;
long long m;
bool used[MAXN];
info a[MAXN], b[MAXN];
priority_queue <int> Heap;
bool cmpp(info x, info y) {return x.p < y.p; }
bool cmpc(info x, info y) {return x.c < y.c; }
int main() {
	read(n), read(k), read(m);
	k = min(n, k);
	for (int i = 1; i <= n; i++) {
		read(a[i].p), read(a[i].c);
		a[i].home = i; b[i] = a[i];
	}
	sort(a + 1, a + n + 1, cmpc);
	sort(b + 1, b + n + 1, cmpp);
	int pa = 1, pb = 1;
	while (pa <= n && pb <= n) {
		if (k >= 1) {
			if (m < a[pa].c) break;
			else {
				ans++; k--;
				m -= a[pa].c;
				used[a[pa].home] = true;
				Heap.push(a[pa].c - a[pa].p);
			}
		} else if (!Heap.empty() && a[pa].c - Heap.top() < b[pb].p) {
			if (m < a[pa].c - Heap.top()) break;
			else {
				ans++;
				m -= a[pa].c - Heap.top();
				Heap.pop();
				used[a[pa].home] = true;
				Heap.push(a[pa].c - a[pa].p);
			}
		} else {
			if (m < b[pb].p) break;
			else {
				ans++;
				m -= b[pb].p;
				used[b[pb].home] = true;
			}
		}
		while (used[a[pa].home]) pa++;
		while (used[b[pb].home]) pb++;
	}
	cout << ans << endl;
	return 0;
}
