#include <bits/stdc++.h>
#define N 100000
using namespace std;
int n,t,ans,cake;
int64_t a[N+2],b[N+2];
priority_queue <int64_t> pQ;
int64_t sumt=0;
int main()
{
    freopen("birthday.inp","r",stdin);
    freopen("birthday.out","w",stdout);
    cin>>n>>t;
    for (int i=0;i<n;i++) cin>>a[i]>>b[i];
    for (int i=0;i<n;i++)
    {
        pQ.push(b[i]);
        sumt+=b[i];
        cake++;
        while (!pQ.empty() && sumt + a[i] >t)
        {
          sumt-=pQ.top();
          cake--;
          pQ.pop();
        }
        ans=max(ans,cake);
    }
    cout<<ans;
    return 0;
}
