#include<bits/stdc++.h>
using namespace std;
struct node{
int h;
int l;
};
int main(){
int n,s,a,b,ans=0,tl=0;
cin>>n>>s;
node t[5005];
cin>>a>>b;
a+=b;
for (int i=0;i<n;i++){
int h,l;
cin>>h>>l;
if(h>a) continue;
t[tl].h=h;t[tl++].l=l;
}
for (int i=0;i<tl-1;i++){
for (int j=i;j<tl-1;j++){
if(t[j].l>t[j+1].l){
swap(t[j],t[j+1]);
}
}
}
for (int i=0;i<tl;i++){
if(s-t[i].l>=0){
s-=t[i].l;
ans++;
}
else {
cout<<ans;
return 0;
}
}
return 0;
}