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

int main() 
{
    ll ans=0,n,k;cin>>n>>k;
    map<ll,ll>a;
    while(n--)
    {
        ll x,y;cin>>x>>y;
            a[x]+=y;    
    }
    ll pre=0,j=0;
    for(auto i=a.begin();i!=a.end();i++)
    {
        if(k>=(i->first)-pre)
        {
            k=k-(i->first)+pre;               
            
            /*
            3 2
            2 3
            5 5
            */
            
            pre=(i->first);
            k=k+i->second;
        }
        else
        {
            cout<<k+pre;
            j=1;
            break;
        }
    }
    if(j==0)
        cout<<k+pre;
}

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

#define ff              first
#define ss              second
#define int             long long
#define w(x)            int x; cin>>x; while(x--)
#define mii             map<int,int>
#define endl            ("\n")
#define vi              vector<int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define pii             pair<int,int>
#define f(i, a, n)      for(int i=a; i<n; i++)
#define fd(i, a, n, d)  for(int i=a; i<n; i+=d)
#define in(a,n)         f(i,0,n){cin>>a[i];}
#define pb              push_back
#define yy              cout<<"YES\n"
#define nn              cout<<"NO\n"
#define kk              cout<<"-1\n"
#define inf             (long long)1e18
#define mod             1000000007LL
#define cc(r)           cout<<r<<" "
#define ce(r)           cout<<r<<endl
#define out(a,n)        f(i,0,n){cc(a[i]);}

//No use
void inout()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
//No use
void ovector_n() {
    ce(1);
}

int32_t main()
{
    inout();
    int T = clock();
    int n, k, a, b;
    cin >> n >> k;
    mii m;
    int tb = k;
    f(i, 0, n) {
        cin >> a >> b;
        m[a] += b;

    }
    for (auto it : m) {
        //cc(a);
        //ce(b);
        a = it.ff;
        b = it.ss;
        if (tb < a)
            break;

        tb += b;
    }

    ce(tb);


}
