#include<bits/stdc++.h>
using namespace std;
long long n,k,m,sum,tot;
struct cow
{
long long price,cheap;
}a[10000000];
bool cmp(cow x,cow y)
{
return x.cheap<y.cheap;
}
bool cmp2(cow x,cow y)
{
return x.price<y.price;
}
int main()
{
scanf("%lld%lld%lld",&n,&k,&m);
for(long long i=1;i<=n;i++)
{
scanf("%lld%lld",&a[i].price,&a[i].cheap);
}
sort(a+1,a+1+n,cmp);
for(long long i=1;i<=k;i++)
{
if(sum<=m&&sum+a[i].cheap<=m)
{
sum+=a[i].cheap;
tot++;
a[i].cheap=0x3f3f3f3f;
a[i].price=0x3f3f3f3f;
}
else
{
break;
}
}
sort(a+1,a+n+1,cmp2);
for(long long i=1;i<=n;i++)
{
if(sum<=m&&sum+a[i].price<=m)
{
sum+=a[i].price;
tot++;
}
else
{
break;
}
}
printf("%lld ",tot);
return 0;
}