#include <iostream>
#include <algorithm>
using namespace std;
//不能忽略血量相同的情况
int ans[5005];
int main(){
int n , m , h , b;
cin >> n >> m >> h >> b;
//当h + b >= x 的时候才能命中
int count = 0;
for(int i=1;i<=n;i++){
int x , y;
cin >> x >> y;
if(h + b >= x){
ans[count++] = y; //不能用i作为下标,用一个count来记录可以命中的蘑菇的血量
}
}
// 或者这样,把血量全部放进一个数组
// 然后进行排序 然后遍历这个数组
// 数组进行一个求和,当sum > m的时候跳出
sort(ans, ans+count);
int sum = 0;
int cnt = 0;
for(int i=0; i<count; i++){
sum += ans[i];
if(sum <= m){
cnt++;
}
/*if(m >= ans[i]){ //这样写也是可以的
cnt++;
m -= ans[i];
}*/
}
cout << cnt << endl;
return 0;
}