#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using llu = unsigned long long;
using ld = long double;

#define CEIL(x, y) (ll)ceil((ld)(x) / (ld)(y))

#define dbgPR(ds) cout << ds.first << ' ' << ds.second
#define dbgLST(ds) for(auto it : ds) cout << it << ' '
#define dbgMP(ds) for(auto it : ds) cout << it.first << ' ' << it.second << '\n'

const double PI = acos(-1.0), g = 9.80665;
const bool unseen = 0;
const ll inf = 1e18 + 505, ninf = -1e18 - 505;
const int MOD = 1000000007;

void solve(void)
{
	ll n, k;
	cin >> n >> k;

	map<ll, ll> mp;

	for(int i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		mp[a] += b;
	}

	ll ans = k;
	for(auto it : mp) {
		if(ans >= it.first) {
			ans += it.second;
		}
		else break;
	}

	cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 

    int testcase = 1;
    // cin >> testcase;
    while(testcase--) {
        solve();
    }    
    return 0;
}
#include <iostream>
#include <vector>
#include  <numeric>
#include<cstdlib>
#include <map>
#include <algorithm>    // std::random_shuffle
#define INF (1<<30)
#define ll long long
using namespace std;


int main() {
    int N;
    cin>>N;
    ll K;
    cin>>K;
    vector<pair<ll,ll>> AB;
    for(int i=1;i<=N;i++) {
        AB.push_back({-1,-1});
        cin>>AB.back().first>>AB.back().second;
    }
    sort(AB.begin(),AB.end());

    ll curr = 0;
    for(int i=0;i<AB.size();i++) {
        ll id = AB[i].first;
        ll B = AB[i].second;
        if (id - curr <= K) {
            K -= id-curr;
            K += B;
            curr = id;
        } else {
            break;
        }
    }

    curr += K;
    cout << curr << endl;

}