#include <bits/stdc++.h>
#define int long long
using namespace std;
struct node{
int x,t;
}a[100005];
bool cmp(node a, node b)
{
if(a.x != b.x)return a.x < b.x;
else return a.t < b.t;
}
priority_queue<int,vector<int>,greater<int> > q;
signed main()
{
int n,m;
cin >> n >> m;
for(int i = 1; i <= n; i++)
{
cin >> a[i].x >> a[i].t;
}
sort(a+1,a+n+1,cmp);
int tmp = 0;
int aknum = 0;
int ans = 0;
for(int i = 1; i <= n; i++)
{
tmp += a[i].x - a[i-1].x;
q.push(a[i].t);
tmp += a[i].t;
aknum++;
while(tmp > m && !q.empty())
{
tmp -= q.top();
q.pop();
aknum--;
}
if(tmp > m)break;
ans = max(ans,aknum);
}
cout << ans << endl;
return 0;
}