#include <bits/stdc++.h>
#define ll long long
#define LIM 300005
#define X first
#define Y second
#define EL cout<<"\n"
using namespace std;
pair <int, int> a[LIM];
int n;
ll k;
bool check(int x)
{
ll cnt = 0;
for (int i = n; i >= 1; i--)
if (a[i].X >= x)
{
cnt += a[i].Y;
}
else break;
return (cnt <= k);
}
int BNS()
{
int l = 1, r = 1e9 + 1;
while (l <= r)
{
int mid = (l + r) / 2;
if (l == mid || mid == r)
{
for (int i = l; i <= r; i++)
if (check(i)) return i;
return 0;
}
if (check(mid)) r = mid;
else l = mid;
}
return 0;
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("TASK.INP", "r", stdin);
freopen("TASK.OUT", "w", stdout);
#endif
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> a[i].X >> a[i].Y;
sort(a + 1, a + 1 + n);
cout << BNS();
return 0;
}