#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
    ll N, K;
    cin >> N >> K;

//    vector<ll> A(N), B(N);
    vector<pair<ll, ll>> friends(N);
    for (int i = 0; i < N; ++i) {
        cin >> friends.at(i).first >> friends.at(i).second;
//        cin >> A.at(i) >> B.at(i);
    }

    sort(friends.begin(), friends.end());

    ll money = K;

    ll pos = 0;

    for (int i = 0; i < N; ++i) {
//        if(pos + money < A.at(i)){
//            cout << pos + money << endl;
//            return 0;
//        }else{
//            money = money - (A.at(i) - pos) + B.at(i);
//            pos = A.at(i);
//        }

        if(pos + money < friends.at(i).first){
            cout << pos + money << endl;
            return 0;
        }else{
            money = money - (friends.at(i).first - pos) + friends.at(i).second;
            pos = friends.at(i).first;
        }
    }

    cout << pos + money << endl;
    return 0;
}

#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F(w,x,y) for(ll w=x; w<y; w++)
#define endl "\n"
#define mod 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

void play()
{
    ll n,k;
    cin>>n>>k;
    ll sum=k;
    vector <pair<ll,ll>> v(n);
    F(i,0,n)
    {
        cin>>v[i].first>>v[i].second;
    }
    sort(all(v));
    F(i,0,n)
    {
        if(sum<v[i].first)
            break;
        else
            sum+=v[i].second;
    }
    cout<<sum<<endl;
}

int main()
{
    //freopen("milkvisits.in","r",stdin);
    //freopen("milkvisits.out","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //pre();
    ll t;
    t=1;
    //cin>>t;
    F(i,1,t+1)
    {
        //cout<<"Case #"<<i<<": ";
        play();
    }
    return 0;
}
