
import java.util.Scanner

import scala.collection.mutable


object Main extends App {
  val sc = new Scanner(System.in)

  val n, k = sc.nextInt()

  val q = mutable.PriorityQueue()(Ordering.by((_:(Int, Int))._1).reverse)

  for(i <- 0 to n - 1) {
    val a, b = sc.nextInt()
    q.enqueue((a, b))
  }

  val (_, ans) = q.foldLeft((0, -1)) {

    case ((cnt, ans), (a, b)) =>
      if (ans > 0) (cnt, ans)
      else if (cnt + b >= k) (cnt, a)
      else (cnt + b, ans)
  }

  println(ans)
}
