#include <bits/stdc++.h>
using namespace std;
int n,s,apple[5005],power[5005];
int a,b;
int x=0;
int main(){
cin>>n>>s>>a>>b;
for (int i=0;i<n;i++){
cin>>apple[i]>>power[i];
}//输入摘第i个苹果的距离和力量
while (1){
int minn=0,i;
for (i=1;i<n;i++){
if (power[i]<minn){minn=i;}
}//求出摘苹果最小所需力量的下标
if (s>=power[i-1]){
if (a+b>=power[i-1]){
x++;
s-=power[i-1];
}
for (int j=i-1;j<n-1;j++){
apple[j]=apple[j+1];
power[j]=power[j+1];
}//移位
n--;
}
else{cout<<x-1;break;}
}
return 0;
}