program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,k,i,a,b
    integer(int64):: cnt(100000)

    cnt(:) = 0
    read*, n,k
    do i=1,n
        read*, a,b
        cnt(a) = cnt(a) + b
    end do

    do i=2,100000
        cnt(i) = cnt(i-1)+cnt(i)
    end do

    do i=1,100000
        if (cnt(i) >= k) then
            print'(i0)', i
            stop
        end if
    end do
end program name