#include<bits/stdc++.h>
using namespace std;
int n,s,a,b;
struct node{
int x,y;
}apple[5010];
int ans=0;
bool cmp(node i,node j){
return i.y<j.y;
}
int main(){
cin>>n>>s;
for(int i=0;i<=n;i++){
cin>>apple[i].x>>apple[i].y;
}
sort(apple+1,apple+n,cmp);
for(int i=0;i<=n;i++){
if(a+b>=apple[i].x&&s>=apple[i].y){
ans++;
s-=apple[i].x;
}
if(s<0) break;
}
cout<<ans<<endl;
return 0;
}
就很蒙,零蛋(紫叶衬红花)求调。