#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define pll pair<long long,long long>
#define vl vector<long long>
#define vll vector<pll>
#define vi vector<int>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAXN = 1000002;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;
const ld EPS = 1e-7;
// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define trav(a, x) for(auto& a : x)
#define fill(x,y) memset(x,y,sizeof(x))
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
ll mul(ll x, ll y)
{
    return (x * 1ll * y) % MOD;
}
 
ll fastpow(ll x, ll y)
{
    ll z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}
ll modinv(ll n,ll p)
{
	return fastpow(n,p-2) ;
}
struct Comp {
  bool operator()(const std::pair<int, int> &a, const std::pair<int, int> &b) {
    if (a.first != b.first) {
      return a.first < b.first;
    }
    return a.second >b.second;
  }
};

int main(int argc, char** argv)
{   sws ;
 // cout<<setprecision(10);
//  ll google=0 ;
   // tcase
    {   
    ll n,k ;
    cin>>n>>k ;
    vector<pair<ll,ll>>p;
    forn(i,n)
    {
    	ll x,y ;
    	cin>>x>>y ;
    	p.pb({x,y}) ;
	}
	sort(p.begin(),p.end()) ;
	ll cur=0 ;
	forn(i,n)
	{
		if(cur+k>=p[i].ff)
		{   k-=(p[i].ff-cur) ;
			cur=p[i].ff ;
			k+=p[i].ss ;
		}
	}
	cur+=k ;
	cout<<cur<<"\n";
    }
return 0 ;
}
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
struct num{
	ll a;
	int b;
	bool operator<(const num& k)const
	{
		return a<k.a;
	}
}nzk[200500];
int main()
{
	int n,flag=0;
	ll k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>nzk[i].a>>nzk[i].b;
	}
	nzk[0].a=0,nzk[0].b=0;
	sort(nzk+1,nzk+n+1);
	for(int i=1;i<=n;i++)
	{
		if(k>=nzk[i].a)
		{
			k+=nzk[i].b; 
		}
		else
		{
			break;
		}
}
	cout<<k<<'\n';
	return 0;
}