#include <bits/stdc++.h>
using namespace std;

#define ll                          long long 
#define ull                         unsigned long long
#define ld                          long double
#define sd                          second
#define ft                          first
#define is                          insert
#define endl                        '\n'
#define all(x)                      x.begin(),x.end()
#define PB                          push_back
#define MP                          make_pair

const long double Pi=(ld)acos((ld)-1);

ll int power(ll int x,ll int y){ll int temp;if(y==0)return 1;temp=power(x,y/2);if(y%2==0)return temp*temp;else return x*temp*temp;}

ll int gcd(ll  int a,ll int b){if(b==0){return a;}else{return gcd(b,a%b);}}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // ll int t;
    // cin>>t;
    // while(t--)
    // {
        ll int n,k,c=0;
        cin>>n>>k;
        vector<pair<ll int,ll int>>vc;
        ll int a=k;
        for(ll int i=0;i<n;i++)
        {
            ll int i1,i2;
            cin>>i1>>i2;
            vc.PB(MP(i1,i2));
        }
        sort(vc.begin(),vc.end());
        
        for(ll int i=0;i<n;i++)
        {
            
            if(k>=(vc[i].ft))
            {
                k+=vc[i].sd;
                // k-=vc[i].ft;
                a+=vc[i].sd;
            }
            else
            {
                break;
            }
            // cout<<k<<" || ";
        }
        cout<<a;
    // }
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素  //遅延セグ木使うときは注意
#define S second //pairの二つ目の要素  //遅延セグ木使うときは注意
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pl = pair<ll, ll>;
using Vs = vector<string>;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;//10の18乗
#define yn {puts("Yes");}else{puts("No");}
#define dame { puts("-1"); return 0;}

int main() {
    ll n,k;
    cin >> n >> k;
    map<ll,ll> ma;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        ma[x]+=y;
    }
    ll now=k;
    ll ans=0;
    for(auto p:ma){
        ll x=p.F,y=p.S;
        if(ans+now<x){
            cout << ans+now << endl;
            return 0;
        }
        else{
            now-=(x-ans);
            ans=x;
            now+=y;
        }
    }
    cout << now+ans << endl;

}
