#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

#define mkp make_pair
#define mkt make_tuple
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
template <class T> void chmin(T &a, const T &b) {
    if (a > b) a = b;
}
template <class T> void chmax(T &a, const T &b) {
    if (a < b) a = b;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    ll K;
    cin >> N >> K;
    vector<ll> A(N + 1, 0), B(N + 1, 0);
    rep(i, N) cin >> A[i + 1] >> B[i + 1];

    A[0] = 0;
    B[0] = K;

    vector<int> ord(N + 1);
    rep(i, N + 1) ord[i] = i;
    sort(all(ord), [&](int a, int b) {
        if (A[a] == A[b])
            return a < b;
        else
            return A[a] < A[b];
    });

    ll money = 0;
    int now = 0;
    while (now <= N) {
        int nex = now;
        while (nex <= N && A[ord[now]] == A[ord[nex]]) {
            money += B[ord[nex]];
            nex++;
        }

        if (nex > N) {
            cout << A[ord[N]] + money << endl;
            return 0;
        }

        if (money >= A[ord[nex]] - A[ord[now]]) {
            money -= A[ord[nex]] - A[ord[now]];
        } else {
            cout << A[ord[now]] + money << endl;
            return 0;
        }
        now = nex;
    }

    return 0;
}
//Classic
// //g++ -std=c++17 -O2 -Wall a.cpp -o test
// _()_
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vll vector<ll>
#define vi vector<int>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define vp vector<pi>
#define vpll vector<pll>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define For(i,a,b) for(ll i=a;i<b;i++)
//#define endl "\n"
#define debug2(x,y) cout<<"This side ----> "<<#x<<" -> "<<x<<" | "<<#y<<" -> "<<y<<endl;
#define debug(x) cout<<"This side    ----> "<<#x<<" -> "<<x<<endl
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define mint map<int,int>
#define mall map<ll,ll>
#define ciN cin
#define gu(a,s) get<a>(s)
#define tin tuple<ll,ll,ll>
#define ter(x,y,z) ((x)?y:z)
#define ul ll
/////////////

const ll maxn = 2e5 + 5;
const ll max_val = 2e5 + 10;
ll mod = 1e9 + 7;
const ll bits = 20;
ll caseNumber = 1;
////////////////////////////////////////////////////////////////

void jabru() {
	ll n, k; cin >> n >> k;
	vpll v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i].F >> v[i].S;
	}
	ll curr = 0;
	sort(all(v));
	for (int i = 0; i < n; i++) {
		ll req = v[i].F - curr;
		if (k < req) {
			break;
		}
		else {
			k -= req;
			k += v[i].S;
			curr += req;
		}
	}
	curr += k;
	cout << curr << endl;
}



bool TestCase = 0;
bool isGoogles = 0;



//////////////////////////////////////////////////////////////////




//////////////////////////////////////////////////////////

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	ll t;
	t = 1;
	if (TestCase) {
		cin >> t;
	}
	while (t--) {
		if (isGoogles) {cout << "Case #" << caseNumber << ": ";} caseNumber++;
		jabru();

	}
	return 0;
}