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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return true; } return false;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return true; } return false;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 n,k;
  cin >> n >> k;
  vector<pll> ab(n);
  REP(i,n)cin >> ab[i].fi >> ab[i].se;
  sort(all(ab));
  int64 cur = 0;
  REP(i,n){
    if(ab[i].fi - cur <= k){
      k -= ab[i].fi - cur;
      k += ab[i].se;
      cur = ab[i].fi;
    }else{
      ANS(cur + k);
      return 0;
    }
  }
  ANS(cur + k);
  return 0;
}
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
int main(void)
{
    int n, k;
    cin >> n >> k;
    map<long, long> mp;
    vector<long long> veca;
    vector<long long> vecb;
    for (int i = 0; i < n; i++)
    {
        long long a, b;
        cin >> a >> b;
        mp[a] += b;
    }
    for (auto i = mp.begin(); i != mp.end(); i++)
    {
        veca.push_back(i->first);
    }
    sort(veca.begin(), veca.end());
    long long have_money = k;
    long long i = 0;
    if (have_money > veca[veca.size() - 1])
    {
        for (long long i = 0; i <= veca.size() - 1; i++)
        {
            have_money += mp[veca[i]];
        }
        cout << have_money << endl;
        return 0;
    }
    else
    {
        while (have_money >= veca[i])
        {
            have_money += mp[veca[i]];
            i++;
        }
    }
    cout << have_money << endl;
}