
import java.util.Scanner

import scala.collection.mutable.PriorityQueue


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

  val n = sc.nextInt()
  val k = sc.nextLong()

  val (_, ans) = Range(0, n).map(_ => (sc.nextInt(), sc.nextInt()))
    .sortWith {
      case (l, r) => l._1 < r._1
    }
    .foldLeft((0L, -1)) {
      case ((cnt, ans), (a, b)) =>
//        println(cnt, ans, a, b)
        if (ans > 0) (cnt, ans)
        else if (cnt + b >= k) (cnt + b, a)
        else (cnt + b, -1)
    }

  println(ans)
}
