#include <iostream>
#include <algorithm>
using namespace std;
int v[5010];
int main() {
int n, w, a, b;
cin >> n >> w;
cin >> a >> b;
int cnt = 0;
for (int i = 0; i < n; i++) {
int x,y;
cin>>x>>y;
if(a+b>=x) v[cnt++] =y;
}
sort(v,v+cnt);
int res =0;
for(int i =0;i<cnt;i++)
{
if(w>=v[i])
{
w-=v[i];
res++;
}
else break;
}
cout<<res<<endl;
return 0;
}