module IntMap = Map.Make (struct type t = int let compare = compare end)

let rec solve k ((a, b) :: abs) =
  if k <= b then a
  else solve (k - b) abs

let () =
  let n, k = Scanf.scanf "%d %d\n" (fun n k -> n, k) in
  Array.init n (fun _ -> Scanf.scanf "%d %d\n" (fun a b -> a, b))
  |> Array.fold_left (fun s (a, b) ->
      IntMap.add a (b + try IntMap.find a s with Not_found -> 0) s) IntMap.empty
  |> IntMap.bindings
  |> solve k
  |> Printf.printf "%d\n"
