#include <bits/stdc++.h>
//#include <atcoder/lazysegtree>
//#include <atcoder/segtree>
//#define rep(i,a,n) for (int i=a;i<n;i++)
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)

#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define rrep(i,a,n) for (int i=n-1;i>=a;i--)
#define ALL(x) x.begin(),x.end()

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pause "read -p 'Press Enter to continue...' var"

using namespace std;
//using namespace atcoder;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

/*
テスト通りますように
　　●
　　/⌒ヽ
　 ｜ 　|/⌒ヽ(ヽ
　 (｀　∥ー⌒) |
　|￣||￣￣￣￣￣|
　|―||―――――|
　|　Ｕ　　　　　|
　|￣￣￣￣￣￣￣|
　|＿＿＿＿＿＿＿|
　　|―――――|
　　|―――――|
ｗｗＷｗｗＷｗＷＷｗ
*/

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

const ll INF = numeric_limits<ll>::max()/4;
const ll MAX = 200005;
const int MOD = 3;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  ll n,k;
  cin >> n >> k;
  vpll p;
  rep(i,n){
    ll a,b;
    cin >> a >> b;
    p.pb(mp(a,b));
  }
  sort(ALL(p));
  ll ans = k;
  rep(i,n){
    if(p[i].fi <= ans) ans += p[i].se;
  }
  cout << ans << endl;
  return 0;
}

/* Goal to be a Master */
      #include <algorithm>
      #include <bits/stdc++.h>
      #include<string>
      using namespace std;
      #define endl "\n"
      #define fo1(i,n) for(int i=1;i<=n;i++)
      #define min3(a,b,c) min(a,min(b,c))
      #define s(v) (ll)v.size()
      #define e(v) v.empty()
      #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
      #define vi vector<int>
      #define ll long long
      #define fi first
      #define se second
      #define db double
      #define U unsigned
      #define P pair<int,int>
      #define vll vector<ll>
      #define pll pair<ll,ll>
      #define pb push_back
      #define eb emplace_back 
      #define mp make_pair
      #define all(x) x.begin(),x.end()
      #define CLR(i,a) memset(i,a,sizeof(i))
      #define fo(i,a,b) for(int i = a;i <= b;++i)
      #define ro(i,a,b) for(int i = a;i >= b;--i) 
      #define ppll pair < pll , pll > 
      #define sd(x) scanf("%d",&x)
      #define sd2(x,y) scanf("%d %d",&x,&y)
      #define sd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
      #define sd4(x,y,z,u) scanf("%d %d %d %d",&x,&y,&z,&u) 
      #define sld(x) scanf("%lld",&x) 
      #define INF 1e18 
      #define eps 0.00001 
      #define le length 
     #define debug(n1) cout << n1 << "\n"

int binex(int base,int pow)
{
    int res=1;
    while(pow)
    {
    if(pow%2)
    { res*=base;pow--;}
    else
    {base*=base;pow=pow/2;}
    }
     return res;
}
      void sieve(int a[],int N)
       {
       for(int i=1;i<=N;i++)
        a[i]=1;
         a[1]=0;
       for(int i= 2;i*i<=N;i++)
       {
         if(a[i])
        {
        for(int j=i*i;j<=N;j+=i)
         a[j]=0;
        }
       }
       }
string CONVERT_TO_BINARY(int s) { 
    string res = ""; 
    while(s != 0) { 
        res += (char)('0' + s % 2); 
        s /= 2; 
    } 
    reverse(res.begin() , res.end()); 
    return res; 
} 
int STOI(string s) { 
    int num = 0; 
    int po = 1; 
    for(int i=s.length()-1;i>=0;i--) 
    { 
        num += po * (s[i] - '0'); 
        po *= 10; 
    } 
    return num; 
} 
int main()
{
	IOS
    int n,m;
    cin >> n >> m;
    ll sum=0;
    vector<pair<ll,int>> v;
    for(int i=1;i<=n;i++)
    {
        ll x,y;
        cin>>x>>y;
        v.pb(mp(x,y));
    }
    sort(all(v));
    ll curr=m;
    //int prev=0;
    /*for(int i=0;i<v.size();i++)
    {
        
        
        if(curr<(v[i].first-prev))
         break;
        curr-=(v[i].first-prev);
        sum+=(v[i].first-prev);
        prev=v[i].first;
        curr+=v[i].second;
    }*/
    for(int i=0;i<v.size();i++)
    {
       if(v[i].first<=curr)
        curr+=v[i].second;
               
    }
    cout<<sum+curr;
    return 0;
}