n, m = gets.to_s.split(' ').map(&:to_i)

as = {}
bs = {}
(0..n - 1).times do |i|
  a, b = gets.to_s.split(' ').map(&:to_i)
  as["#{i}"] = a
  bs["#{i}"] = b
end

max_sal = 0
(0..m - 1).each do |i|
  remaining = m - i
  as = as.sort {|(k1, v1), (k2, v2)| v2 <=> v1 }.select {|k, v| v < remaining }
  
  fixed_bs = []
  as.keys.each do |a_i|
    fixed_bs << bs[a_i]
  end
  if fixed_bs != []
    max_sal = fixed_bs.max
end

puts max_sal

