#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define int long long
int32_t main() {
    int n,k;
    cin>>n>>k;
    vector<pair<int,int>> v;
  
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        v.push_back({a,b});
    }
    sort(v.begin(),v.end());
    int p=0,av=k;
    for(int i=0;i<n;i++)
    {
        int dis=v[i].F-p;
        if(dis<=av)
        {
            av=av-dis;
            p=v[i].F;
            av+=v[i].S;
        }
        else
        {
            p=p+av;
            av=0;
            break;
        }
    }
    if(av>0)
    {
        p=p+av;
    }
    cout<<p;
	return 0;
}

#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <set>
#include <bitset>
#include <iterator>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define MOD 1000000007
#define len(vc) int(vc.size())
#define fore(x,vc) for(auto &x: vc)
#define all(vc) vc.begin(), vc.end()
#define allr(vc) vc.rbegin(), vc.rend()
#define forr(i,a,b) for(int i = a;i <= b;++i)
#define forn(i,n) for(int i = 0; i < int(n);++i)
#define gauss(n) (((n) * ((n) + 1)) / 2)

#ifdef LOCAL
#include "debugger.h"
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);

	int N;
	int64_t cash;
	cin >> N >> cash;
	vector<pair<int64_t,int>> A(N);
	for(auto &[x,y]: A)
		cin >> x >> y;

	sort(all(A));
	int64_t ans = 0;
	for(auto &[x,y]: A) {
		int64_t dis = x - ans;
		debug(ans,cash,dis);
		if(dis <= cash) {
			ans += dis;
			cash -= dis;
			cash += y;
		} else {
			cout << ans + cash << endl;
			return 0;
		}
	}

	cout << ans + cash << endl;

	return 0;
}
