// Bismillahir Rahmanir Rahim
//============================
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define endl        "\n"
#define infL        LLONG_MAX
#define infI        INT_MAX
#define pb          push_back
#define fo(i,a,b)   for(int i=a;i<b;i++)
#define fo2(i,a,b)  for(int i=a;i<=b;i++)
#define rfo(i,a,b)  for(int i=a; i>=b;i--)
#define precise(x,y)cout<<fixed<<setprecision(y)<<x<<endl;
#define MAX         100010
#define yes         cout<<"YES"<<endl
#define no          cout<<"NO"<<endl
#define bye         return 0
#define debug       cout<<"\nDebug\n";
#define debug2      cout<<"\nDebug2\n";
#define PEREGRINE_FALCON {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

typedef pair<ll,ll>PII;
double epsilon = 0.0000001f;
ll mod=1e9+7;
double Pi =acos(-1);

void print(vector<ll>V)
{
      cout<<"\n---------------Vector checking start-------------------\n";
      ll sz=V.size();
      fo(i,0,sz){cout<<V[i]<<"  ";}
      cout<<"\n----------------Vector checking end--------------------\n";
}

void print(ll arr[], ll n)
{
      cout<<"\n---------------Array checking start-------------------\n";
      fo(i,0,n){cout<<arr[i]<<" ";}
      cout<<"\n----------------Array checking end--------------------\n";
}

struct strct{
      ll a,b;
};

bool cmp(strct A, strct B)
{
      return A.a<B.a;
}

int main()
{
      PEREGRINE_FALCON
      //freopen("inputNew.txt", "r", stdin);

      ll testCase=1;
      //cin>>testCase;
      while(testCase--){
            ll n,m,k,x,y,z,a,b,c,d,mn,mx,temp,cnt,ans,sum,sz,len;
            cin>>n>>k;

            struct strct s[n];
            fo(i,0,n){cin>>s[i].a>>s[i].b;}
            sort(s,s+n,cmp);

            cnt=k;
            for(int i=0; i<n; i++){
                  if(s[i].a > cnt) break;
                  cnt+=s[i].b;
            }
            cout<<cnt<<endl;

      }

      bye;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,k,i,j,num,sum=0,x,y;
    cin>>n>>k;
     vector< pair <long long,long long> > vect;
   for (int i=0; i<n; i++){
        cin>>x>>y;
        vect.push_back( make_pair(x,y) );
   }
    sort(vect.begin(), vect.end());
  for(i=0;i<n;i++)
  {
      if(vect[i].first>k)
      break;
        k=k+vect[i].second;
  }
  cout<<k<<endl;
}
