#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,k;cin>>n>>k;
    vector<pair<ll,ll>> a(n);
    rep(i,n) cin>>a[i].first>>a[i].second;
    sort(a.begin(),a.end());
    ll tmp=0;
    rep(i,n){
        ll x=a[i].first,y=a[i].second;
        if(k<x-tmp){
            cout<<tmp+k<<endl;
            return 0;
        }
        k+=y;
    }
    cout<<tmp+k<<endl;
}
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
  long long k, n;
  pair<long long, long long> m[(int)2e5];
  scanf("%lld%lld", &n, &k);
  
  for (int i=0;i<n;++i){
  	scanf("%lld%lld", &m[i].first, &m[i].second);
  }
  
  sort(m,m+n);
  
  long long current = 0;
  for (int i=0;i<n;i++){
    if (m[i].first-current > k) break;
    k -= m[i].first - current;
    current = m[i].first;
    k += m[i].second;
  }
  cout << current + k <<endl;
  return 0; 
}