#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int main(){
  int N; cin >> N;
  ll K; cin >> K;
  vector<pair<ll,ll>> A(N);
  rep(i,N) cin >> A[i].first >> A[i].second;
  sort(A.begin(),A.end());
  for(auto a : A){
    if(K < a.first) break;
    K += a.second;
  }
  cout << K << "\n";
  return 0;
}



struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_instance;



#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,k;
map<int,int>m;
int a[200005],b[200005];
set<int>s;
signed main()
{
	scanf("%lld %lld",&n,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%lld %lld",&a[i],&b[i]);
		m[a[i]]+=b[i];
		s.insert(a[i]);
	}

	set<int>::iterator it=s.begin();
	int t=0;
	while(k)
	{
		if(it==s.end())
		{
			t+=k;
			break;
		}
		k-=(*it-t);
		if(k>=0)
		{
			k+=m[*it];
			t=*it;
			it++;
			
		}	
		else
		{
			k+=(*it-t);
			t+=k;
			break;
		} 
	}
	printf("%lld\n",t);



	return 0;
}