n,w=gets.split.map &:to_i a=(1..n).map{gets.split.map &:to_i} p (a.filter{|a,b|b<=w}.max||[-1,0])[0]