#include <bits/stdc++.h>
using namespace std;
int sum;
struct apple
{
int x;
int y;
}ap[5005];
bool cmp(apple p,apple q)
{
return p.y<q.y;
}
int main ()
{
int n,s;
int a,b;
cin>>n>>s;
cin>>a>>b;
int len=a+b;
for (int i=1;i<=n;i++)
{
cin>>ap[i].x>>ap[i].y;
}
sort(ap+1,ap+n+1,cmp);
for (int i=1;i<=n;i++)
{
if (len>=ap[i].x)
{
if (ap[i].y<s)
{
sum++;
s-=ap[i].y;
}
}
if (s<=0)
break;
}
cout<<sum;
}