//USACO 2017 December Contest, Gold
//Problem 3. Haybale Feast
#include<bits/stdc++.h>
#define int long long
using namespace std;
void usaco(){
freopen("hayfeast.in","r",stdin);
freopen("hayfeast.out","w",stdout);
}
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
usaco();
int n,m; cin>>n>>m;
pair<int,int> a[n]; for(auto &[x,y]:a) cin>>x>>y;
int s=0,ans=2e18,j=0;
multiset<int>st;
for(int i=0;i<n;i++){
auto [x,y]=a[i];
s+=x; st.insert(y);
while(j<i && s-a[j].first >=m) {
st.erase(st.find(a[j].second));
s-=a[j].first;
j++;
}
if(s>=m) ans=min(ans,*st.rbegin());
}
cout<<ans;
}
Ly9VU0FDTyAyMDE3IERlY2VtYmVyIENvbnRlc3QsIEdvbGQKLy9Qcm9ibGVtIDMuIEhheWJhbGUgRmVhc3QKI2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBpbnQgbG9uZyBsb25nCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnZvaWQgdXNhY28oKXsKCWZyZW9wZW4oImhheWZlYXN0LmluIiwiciIsc3RkaW4pOwoJZnJlb3BlbigiaGF5ZmVhc3Qub3V0IiwidyIsc3Rkb3V0KTsKfQoKc2lnbmVkIG1haW4oKSB7Cglpb3M6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7IGNpbi50aWUobnVsbHB0cik7Cgl1c2FjbygpOwoJaW50IG4sbTsgY2luPj5uPj5tOwoJcGFpcjxpbnQsaW50PiBhW25dOyBmb3IoYXV0byAmW3gseV06YSkgY2luPj54Pj55OyAKCWludCBzPTAsYW5zPTJlMTgsaj0wOwoJbXVsdGlzZXQ8aW50PnN0OwoJZm9yKGludCBpPTA7aTxuO2krKyl7CgkJYXV0byBbeCx5XT1hW2ldOwoJCXMrPXg7IHN0Lmluc2VydCh5KTsKCQl3aGlsZShqPGkgJiYgcy1hW2pdLmZpcnN0ID49bSkgewoJCQlzdC5lcmFzZShzdC5maW5kKGFbal0uc2Vjb25kKSk7CgkJCXMtPWFbal0uZmlyc3Q7CgkJCWorKzsKCQl9CgkJaWYocz49bSkgYW5zPW1pbihhbnMsKnN0LnJiZWdpbigpKTsKCX0KCWNvdXQ8PGFuczsKfQo=