#include <bits/stdc++.h>        //12.25 , -7,
using namespace std;
typedef long long ll;
typedef unsigned long long int ull;
#include <fstream>
#define int unsigned long long int
#define mod 1000000007
#define watch(x) cout<<(#x)<<" is "<<(x)<<"\n"
#define watch2(x,y) cout<<(#x)<<" is "<<(x)<<" and "<<(#y)<< " is " <<(y)<<"\n"
int powerr(int m,int n){if(m==0 || n==1)return m;if(n==0)return 1;int ans = 1;if(n&1)ans = m*powerr(m,n-1);else {ans = powerr(m,n/2);ans = ans * ans;}return ans%mod;}
int gcdd(int a,int b){if(b==0)return a;   return gcdd(b,a%b);}
int lcmm(int a,int b){return (a*b)/gcdd(a,b);}

bool comparee(pair<int,int> &a,pair<int,int> &b){
    return a.first < b.first;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    vector<pair<int,int>> v;
    for(int i=0;i<n;++i){
        int a,b;cin>>a>>b;
        v.push_back({a,b});
    }
    sort(v.begin(),v.end(),comparee);
    int summ = k;
    int pos = 0;
    for(int i=0;i<n;++i){
        if(v[i].first-pos<=summ){
            summ = summ - (v[i].first - pos);
            summ = summ + v[i].second;
            pos = v[i].first;
        }
        else {
            pos = pos + summ;
            summ = 0;
            break;
        }
    }
    pos = pos + summ;
    cout<<pos;
    return 0;
}

//Never stop trying
#include "bits/stdc++.h"
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef long long ll;
#define int ll
typedef string str;
typedef long double ld;
typedef pair<int, int> pi;
#define fi first
#define se second
typedef vector<int> vi;
typedef vector<pi> vpi;
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)

const int MOD = 1e9 + 7; //998244353
const ll INF = 1e18;
const int MX = 2e5 + 10;
const int nx[4] = {0, 0, 1, -1}, ny[4] = {1, -1, 0, 0}; //right left down up

template<class T> using V = vector<T>;
template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } // divide a by b rounded up
//constexpr int log2(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
ll random(ll a, ll b){
    return a + rng() % (b - a + 1);
}
#ifndef LOCAL  
#define cerr if(false) cerr
#endif
#define dbg(x) cerr << #x << " : " << x << endl; 
#define dbgs(x,y) cerr << #x << " : " << x << " / " << #y << " : " << y << endl;
#define dbgv(v) cerr << #v << " : " << "[ "; for(auto it : v) cerr << it << ' '; cerr << ']' << endl;
#define here() cerr << "here" << endl;

void IO() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout);
#endif
}
/////////////////////////ONLY CLEAN CODES ALLOWED/////////////////////////


int32_t main() {
    boost; IO();

    int N,K; cin>>N>>K;
    vpi vec={{0,K}};
    FOR(i,0,N){
        int a,b; cin>>a>>b;
        vec.eb(a,b);
    }
    sort(all(vec));

    int ans=0,r=0;
    FOR(i,0,sz(vec)){
        r+=vec[i].se;

        if(i==sz(vec)-1) ans+=r; 
        else{
            int d=vec[i+1].fi-vec[i].fi;
            if(d<=r){
                ans+=d;
                r-=d; 
            }
            else{
                ans+=r;
                break;
            }
        }
    }
    cout << ans << endl;
    

    return 0;
}
//Change your approach 