#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define vi vector<int>
#define pb push_back
#define pop pop_back
using namespace std;
int main(){
ll n,k;
cin>>n>>k;
vector<pair<ll,ll>>v;
while(n--)
{
    ll x,y;
    cin>>x>>y;
    v.pb({x,y});

}
sort(v.begin(),v.end());
for(auto it:v)
{
    ll a=it.first;
    ll b=it.second;
    if(k<a)
    {
        cout<<k<<endl;
        return 0;
    }
    else
    k+=b;
}
cout<<k<<endl;
return 0;
}
#include<bits/stdc++.h>
using namespace std;

#define FASTIO	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(A,val) memset(A,val,sizeof(A))
#define fi(a,b) for(int i=a;i<=b;++i)
#define fj(a,b) for(int j=a;j<=b;++j)
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define DEBUG(a...) cout<<#a<<": ";for(auto &it:a)cout<<it<<" ";cout<<endl;
#define debug(a)cout<<#a<<": "<<a<<"\n";
#define hola cout<<"hola"<<endl;
#define int long long
// ---------------------------------------------------------------------------
const int mod = 1e9+7;
const int maxn = 2e5 + 9;

// ---------------------------------------------------------------------------
void init(){}
// ---------------------------------------------------------------------------
void test_case(int tc)
{
    // cout<<"Case #"<<tc<<": ";
    int n,k;cin>>n>>k;
    vector<pii>arr(n);
    fi(0,n-1)cin>>arr[i].first>>arr[i].second;
    sort(all(arr));
    int currPos = 0;
    fi(0,n-1){
        ll nextPos = arr[i].first;
        ll cost = nextPos-currPos;
        if(cost>k){
            cout<<currPos+k;
            return;
        }
        k-=cost;
        currPos = nextPos;
        k+=arr[i].second;
    }
    cout<<currPos+k;
    init();
}

int32_t main()
{
    FASTIO;
    #ifndef ONLINE_JUDGE
         freopen("input.txt","r",stdin);
         // freopen("output.txt","w",stdout);
    #endif
    
    int t=1;
    //cin>>t;
    for(int tc=1;tc<=t;++tc)test_case(tc);
}	