#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i, n) for (ll i = 0; i < n; i++)
#define revf(i, n) for (ll i = n - 1; i >= 0; i--)
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define rep1(i, b) for (ll i = 1; i <= b; i++)
#define inp(a, n)              \
	for (ll i = 0; i < n; i++) \
	cin >> a[i]
#define outp(a, n)             \
	for (ll i = 0; i < n; i++) \
	cout << a[i] << " "
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) (((a) * (b)) / gcd((a), (b)))
#define pb push_back
#define mpr make_pair
#define ins insert
#define BINSC binary_search
#define BITOUT __builtin_popcount
#define mem(x, n) memset(x, n, sizeof(x))
#define fast                          \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);
#define test  \
	ll t;     \
	cin >> t; \
	while (t--)
#define cn cout << "\n";
int main()
{
	fast
	ll n,k;
	cin>>n>>k;
	ll ar[n],br[n];
	vector<pair<ll,ll>>v;
	forr(i,n)
	{
		ll a,b;
		cin>>a>>b;
		v.pb(make_pair(a,b));
	}
	sort(v.begin(),v.end());
	ll prev=0;
	ll out=0;
	for(auto i:v)
	{
		ll x=i.first;
		ll y=i.second;
		if(x-prev<=k)
		{
			out=x;
			k=k-(x-prev);
			k+=y;
			prev=x;
		}
	}
	cout<<out+k;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)//iをaからn
#define per(i,n,a) for (int i=a-1;i>=n;i--)//iをnからa
#define db(x) cout << #x << " = " << x << endl
#define db2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; //デバッグ用
#define all(x) (x).begin(), (x).end()
#define INF 10000000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define mp make_pair
#define pb push_back
#define F first
#define S second
typedef long long ll;
//sort(all(a)); ソート
//sort(all(a),greater<int>()); 逆順ソート
//a.erase(unique(all(a)), a.end()); ソート後に重複を削除
//cout<< std::fixed << std::setprecision(15)<<0.000001<<endl; 小数点以下を表示させる
//vector<vector<int>> data(3, vector<int>(4)); int型の2次元配列(3×4要素の)の宣言
int main() {
  ll n,k;
  cin >> n>>k;
  vector<pair<ll,ll>> friends;
  ll a,b;
  rep(i,0,n){
    cin>>a>>b;
    friends.pb(mp(a,b));
  }
  
    ll ans=k;
    sort(all(friends));
    
    rep(i,0,n){
        if(ans<friends.at(i).F)break;
        ans+=friends.at(i).S;
    }


  cout<<ans;
  return 0;
}