#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ll long long
#define pi (3.141592653589)
#define mod 1000000007
#define float double
#define pb push_back
// #define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rfo(i, a, b) for (int i = (int)a; i >= (int)b; i--)
#define fo(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define see(x) cout << (x) << endl
#define hh cout << endl
#define INF 1e18
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

template <typename C,
          typename T = std::decay_t<decltype(*begin(std::declval<C>()))>,
          typename std::enable_if<!std::is_same<C, std::string>::value>::type * = nullptr>
std::ostream &operator<<(std::ostream &os, const C &container)
{
    bool first = true;
    std::stringstream ss;
    ss << '[';
    for (const auto &x : container)
    {
        if (!first)
        {
            ss << ", ";
        }
        first = false;
        ss << x;
    }
    ss << ']';
    return os << ss.str();
}
template <class T1, class T2>
std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &p)
{
    os << '{' << p.first << ", " << p.second << '}';
    return os;
}

ll mod_pow(ll a, ll b)
{
    if (b < 0)
        return 0;
    a %= mod;
    if (b == 0)
        return 1;
    if (b == 1)
        return a % mod;
    if (b == 2)
        return ((a % mod) * (a % mod)) % mod;
    return (mod_pow(mod_pow(a, b / 2), 2) * mod_pow(a, b % 2)) % mod;
}

bool isPrime(int n)
{
    if (n == 1)
        return false;
    if (n == 2)
        return true;
    for (int i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}

int32_t main()
{
    fast int tc = 1;
    // cin>>tc;
    while (tc--)
    {
        int n, m;
        cin >> n;
        cin >> m;

        int a = 0;

        int nl = 0, ol = 0;
        nl = ol + m;

        int pre[n + 1] = {0};
        map<int, int> mp;

        vector<int> v;

        fo(i, 1, n)
        {
            int a, b;
            cin >> a >> b;
            v.push_back(a);
            mp[a] += b;
        }
        sort(all(v));

        // for (auto it = next(mp.begin()); it != mp.end();it++){

        //     // if(it!=mp.begin())

        //     it->second += prev(it)->second;
        // }

        for (int i = 0; i < n; i++)
        {

            if (nl < v[i])
            {
                break;
            }
            else
            {
                nl += mp[v[i]];
                mp[v[i]] = 0;
            }
        }

        cout << nl;
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0,endrep=(n); i<endrep; ++i)
#define rep1(i,n) for(ll i=1,endrep=(n); i<=endrep; ++i)
#define revrep(i,n) for(ll i=(ll)(n)-1; i>=0; --i)
inline constexpr ll Inf = (1ULL << 60) -123456789;
#define fastio cin.tie(0); ios_base::sync_with_stdio(false); cout<<fixed<<setprecision(10);
#define newl '\n'
#define YN(e) ((e)?"Yes":"No")
#define all(a) begin(a),end(a)
#define rall(a) rbegin(a),rend(a)
#define delif(c,pred) (c).erase(remove_if(all(c),(pred)), end(c))
template <class T,class U> bool updmax(T& a, U b) { if(b>a){ a=b; return true;} return false;}
template <class T,class U> bool updmin(T& a, U b) { if(b<a){ a=b; return true;} return false;}
inline constexpr int Mod = 1000000007;
//inline constexpr int Mod = 998244353;
#define dbg(a) cerr << #a << ": " << (a) << endl;
#define dbgs(s) cerr << #s << endl;
#define dbg1(a,n) cerr<<#a<<": "; rep(i,n) cerr<<(a)[i]<<" "; cerr<<endl;
#define dbg2(m,h,w) cerr<<#m<<":"<<endl; rep(i,(h)){ rep(j,(w))cerr<<(m)[i][j]<<" "; cerr<<endl; }
template <class T, class U> ostream& operator << (ostream& os, pair<T,U> v) {os<<v.first<<","<<v.second;return os;}
template <class T, size_t N> ostream& operator << (ostream& os, array<T,N> v) {rep(i,N)os<<v[i]<<(i+1<(ll)N?" ":"");return os;}
int rng(int n) { return rand()/(RAND_MAX+1.0)*n; }
inline constexpr int offset[] = {1,0,-1,0,1};

int main() {
    fastio;
    ll ans{};
    ll N,K;
    cin >> N >> K;
    vector<array<ll,2>> a(N);
    rep(i,N) rep(j,2) cin >> a[i][j];
    sort(all(a));
    ll p{};
    rep(i,N) {
        ll c = a[i][0]-p;
        if (c > K) break;
        K -= c;
        K += a[i][1];
        p = a[i][0];
    }
    ans = p + K;
    cout << ans << endl;
}
