#include <bits/stdc++.h>

#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 5,4,3,2,1))
#define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
#define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,N,...) N
#define macro_dispatcher(macro,...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(macro,nargs) macro_dispatcher__(macro, nargs)
#define macro_dispatcher__(macro,nargs) macro_dispatcher___(macro, nargs)
#define macro_dispatcher___(macro,nargs) macro ## nargs
#define DBN(...) macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)
#define DBN1(a)            cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)        cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)        cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)    cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)    cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"

#define endl '\n'
#define DBN1D(x) cerr<<#x<<endl;for(auto _:x){cerr<<_<<" ";}cerr<<endl
#define DBN2D(x) cerr<<#x<<endl;for(auto _:x){for(auto __:_){cerr<<__<<" ";}cerr<<endl;}cerr<<"------"<<endl
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp(x,y) make_pair(x,y)
#define mpp(w,x,y,z) mp(mp(w,x),mp(y,z))
using namespace std;
typedef long long loli;
typedef vector<loli> vl;
typedef vector<vl> vvl;
typedef pair<loli,loli> pll;
typedef pair<pll,pll> pllll;

void solve(){
	loli n,k;
	cin>>n>>k;
	map<loli,loli> mp;
	for(loli i=0;i<n;++i){
		loli x,y;
		cin>>x>>y;
		mp[x]+=y;
	}
	vector<pll> f(1);
	f[0]=mp(0,k);
	for(auto&x:mp){
		f.push_back(x);
	}
	// // for(int i=1;i<=n;++i){
	// // 	int x,y;
	// // 	cin>>x>>y;
	// // 	f[i]={x,y};
	// // }
	// // sort(f.begin(),f.end());
	
	// for(int i=0;i<=n;++i){

	// }

	loli tmp=0;

	for(loli i=0;i<=f.size();++i){
		f[i].second+=tmp;
		tmp=f[i].second;
	}

	// for(auto x:f){
	// 	cout<<x.first<<" "<<x.second<<endl;
	// }
	for(loli i=0;i<f.size();++i){
		if(f[i].second<f[i+1].first){
			cout<<f[i].second<<endl;
			return;
		}
	}
	cout<<f.back().second<<endl;
}

int main(){
    sync;
    solve();
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=int(b)-1;i>=int(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void Main()
{
    int n;
    ll k;
    cin >> n >> k;
    vector<pair<ll, ll>> v(n);
    rep(i, n){
        ll a, b;
        cin >> a >> b;
        v[i] = {a, b};
    }
    sort(v.begin(), v.end());
    rep(i, n){
        auto [a, b] = v[i];
        if (a > k) {
            cout << k << endl;
            return;
        } else{
            k += b;
        }
    }
    cout << k << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    // int t; cin >> t; rep(i, t)
    Main();
    return 0;
}
