#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define SIZE(x) ll(x.size())
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
typedef pair<ll, ll> P;
int main()
{
    ll N, K;
    cin >> N >> K;
    vector<P> AB(N);
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        AB[i] = {a, b};
    }

    sort(all(AB));

    ll ans = 0;
    ll place = 0;
    rep(i, N) {
        ll diff = place + K;
        if (AB[i].first <= diff) {
            K -= (AB[i].first - place);
            place = AB[i].first;
            K += AB[i].second;
        }
        else {
            break;
        }
    }

    cout << place + K << endl;
    return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main()
{ 
  long long n,w;cin>>n>>w;
  long long a[200001]={},i,j,x,y,z;
  for(i=0;i<n;i++)
  { 
    cin>>x>>y>>z;
    a[x]+=z;
    a[y]-=z;
  }
  for(i=1;i<=200000;i++)
  { 
    a[i]+=a[i-1];
    
  }
  for(i=0;i<=200000;i++)
  {
       if(a[i]>w) break;
  }
  if(i==200001)
    cout<<"Yes\n";
  else
    cout<<"No\n";
  return 0;
}
  