#8#9#10#13没过,用的贪心
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct Node{
int x,t;
bool operator<(const Node &Noode)const{
return x+t<Noode.x+Noode.t;
}
Node(int xx,int tt):x(xx),t(tt){}
};
priority_queue<Node,vector<Node>,less<Node> > q;
signed main(){
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++){
int x,t;
cin>>x>>t;
if(x+t<=m) q.push(Node(x,t));
}
int noww=0,sum=0,ans=0;
while(sum<=m&&!q.empty()){
Node s=q.top();
q.pop();
if(s.x>noww) noww=s.x;
if(sum+noww+s.t<=m){
sum+=s.t;
ans++;
}
}
cout<<ans;
return 0;
}