#include<bits/stdc++.h>
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define w(x)            int x; cin>>x; while(x--)
#define mii             map<int,int>
#define endl            ("\n")
#define vi              vector<int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define pii             pair<int,int>
#define f(i, a, n)      for(int i=a; i<n; i++)
#define fd(i, a, n, d)  for(int i=a; i<n; i+=d)
#define in(a,n)         f(i,0,n){cin>>a[i];}
#define pb              push_back
#define yy              cout<<"YES\n"
#define nn              cout<<"NO\n"
#define kk              cout<<"-1\n"
#define inf             (long long)1e18
#define mod             1000000007LL
#define cc(r)           cout<<r<<" "
#define ce(r)           cout<<r<<endl
#define out(a,n)        f(i,0,n){cc(a[i]);}

//No use
void inout()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
//No use
void ovector_n() {
    ce(1);
}

int32_t main()
{
    inout();
    int T = clock();
    int n, k, a, b;
    cin >> n >> k;
    mii m;
    int tb = k;
    f(i, 0, n) {
        cin >> a >> b;
        m[a] += b;

    }
    for (auto it : m) {
        //cc(a);
        //ce(b);
        a = it.ff;
        b = it.ss;
        if (tb < a)
            break;

        tb += b;
    }

    ce(tb);


}

#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define int long long
using namespace std;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MAXIN(x) max_element(ALL(x)) - x.begin();
#define MIN(x) *min_element(ALL(x))
#define MININ(x) min_element(ALL(x)) - x.begin();
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000  //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265358979323846

using namespace std;

signed main() {
    int n, k;
    cin >> n >> k;
    vector<int> A(n);
    vector<int> B(n);
    vector<pair<int, int>> S(n);
    REP(i, n) {
        cin >> S[i].first;
        cin >> S[i].second;
    }

    sort(ALL(S));

    int ns = 0;

    for (int i = 0; i < n; i++) {
        if (k - S[i].first >= 0) {  //友達の島までつくか
            k += S[i].second;

        } else {
            ns += k;
            goto end;
        }
    }

    if (k > 0) {
        ns += k;
    }

end:
    cout << ns << endl;
}
