#include <cstdio>
#include <algorithm>
#define N 200010
using namespace std;
long long n,k,cur=0;
struct node{
	long long a,b;
	bool operator<(const node x)const{
		return a<x.a;
	}
}c[N];
int main(){
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%lld%lld",&c[i].a,&c[i].b);
	sort(c+1,c+1+n);
	for(int i=1;i<=n;i++){
		if(cur+k<c[i].a){
			printf("%lld",cur+k);
			return 0;
		}
		k=c[i].b-c[i].a+cur+k;
		cur=c[i].a;
	}
	printf("%lld",cur+k);
	return 0;
}
//Radhe Radhe
#include<bits/stdc++.h>
#define FASTIO_  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod 1000000007

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define en '\n'
#define itr(i,n)    for(ll i=0; i<n; i++)
#define itr_ab(i,a,b)    for(ll i=a; i<=b; i++)
#define itrV(i,n)    for(ll i=0; i<v.size(); i++)
#define fixed cout.setf(ios::fixed);
#define precise cout.precision(2);
#define Dont_Quit int main(void)
#define Avada_Kedavra return 0;
#define yes cout<<"Yes"<<'\n'
#define no cout<<"No"<<'\n'
using namespace std;
bool cmp(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    if(a.fi<b.fi) return 1;
    return 0;
}
Dont_Quit
{
    FASTIO_
    ll t,n,i,j,k,ans;
    t=1;
    while(t--)
    {
        ll n,k,ans;
        cin>>n>>k;
        ans=k;
        ll a[n],b[n],cur=0;
        bool ok=1;
        vector<pair<ll,ll>>v;
        itr(i,n)
        {
            cin>>a[i]>>b[i];
            v.pb(mp(a[i],b[i]));
        }
        sort(v.begin(),v.end(),cmp);
        for(auto it:v)
        {
            if(ans>=it.fi) ans+=it.se;
            else break;
        }




        cout<<ans<<en;

    }


    Avada_Kedavra
}

