#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
struct ab{
int h,f;
}s[100000];
bool cmp(ab a,ab b){
if(a.f<b.f) return true;
return false;
}
int main(){
int n,x,a,b;
cin>>n>>x>>a>>b;
int len=a+b;
int tot=0;
for(int i=1;i<=n;i++){
int temp1,temp2;
cin>>temp1>>temp2;
if(temp1<=len){
tot++;
s[tot].h=temp1;
s[tot].f=temp2;
}
}
sort(s+1,s+1+tot,cmp);
int ans=0;
for(int i=1;i<=tot;i++){
x-=s[i].f;
ans++;
if(x<=0) break;
}
cout<<ans;
return 0;
}