#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,K;cin>>N>>K;
  vector<pair<int,int>>V(N);
  for(int X=0;X<N;X++){
    int A,B;cin>>A>>B;
    V[X]={A,B};
  }
  sort(V.begin(),V.end());
  int now=0;int p=K;
  for(int X=0;X<N;X++){
    if(V[X].first-now<=p){
      p-=V[X].first-now;p+=V[X].second;now=V[X].first;
    }
    else{
      now+=p;p=0;break;
    }
  }
  now+=p;
  cout<<now<<endl;
}
#include <bits/stdc++.h>
 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef long int li;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define test ll t; cin >> t; while(t--)
#define print_tc(t, c) cout << "Case #" << t << ": " << c << "\n"; 
const long long int dx[4] = {0, 0, -1, 1}, dy[4] = {1, -1, 0, 0}; 
const long long int cons = 100005, ncr_cons = 100005;
const long long int MOD = 1000000007; // const long long int MOD = 998244353; 
const long long int const_INT_MAX = 1000000000000000000, const_INT_MIN = -1 * 1000000000000000000;
using namespace std;
bool sortinrev(const pair<ll,ll> &a, const pair<ll,ll> &b){return (a.first > b.first);}
bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b){return (a.second < b.second);}
bool sortbysecinrev(const pair<ll,ll> &a, const pair<ll,ll> &b){return (a.second > b.second);}
ll gcd(ll x, ll y){return (ll)(__gcd(x, y));}   
ll lcm(ll x, ll y){return (ll)((x * y) / gcd(x, y));}
ll mod_expo(ll x, ll y, ll p){  
    if((x + p) % p == 0) return 0; 
    ll res = 1; x = (x + p) % p; 
    while (y > 0){   
        if(y & 1) res = (res*x + p) % p; 
        y = y>>1; x = (x*x + p) % p;  
    }  
    return res;    
}
void usaco(string str = ""){    
    fastio; 
    if(str.size()){
        freopen((str + ".in").c_str(), "r", stdin); 
        freopen((str + ".out").c_str(), "w", stdout);
    }   
}  
int main(){ 
    usaco();
    ll n, k; cin >> n >> k; vector<pair<ll, ll>> a(n); 
    for(ll i=0;i<n;i++) cin >> a[i].first >> a[i].second; sort(a.begin(), a.end()); 
    ll i=0, sum=k; while(i < n && a[i].first <= sum){
        sum += a[i].second; i++; 
    }
    cout << sum << "\n"; 
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; 
}

