let () =
  let open Int64 in
  let len, b = Scanf.scanf "%d %Ld\n" (fun a b -> a, b) in

  let arr = Array.make len (0L,0L) in
  for i = 0 to (len-1) do
    let c = Scanf.scanf "%Ld %Ld\n" (fun a b -> a, b) in
    Array.set arr i c
  done;
  let t = ref 0L in

  let arr_l = Array.make len (0L,0L) in
  let arr_r = Array.make len (0L,0L) in

  for i = 0 to (len-1) do
    let distance = fst (Array.get arr i) in

    let cal = Int64.add (snd (Array.get arr i)) 
        ( if (i=0) then 0L else (snd (Array.get arr_l (i-1)))) in

    let d_sub = if (i=0) then 0L else (fst (Array.get arr_l (i-1))) in
    let d_sub = Int64.sub distance d_sub in
    let cal = Int64.sub cal d_sub in

    if (cal > !t) 
    then (t := cal)
    else ();
    Array.set arr_l i (distance, cal)

  done;
  for i = 0 to (len-1) do
    let i = len-1-i in
    let distance = Int64.sub b (fst (Array.get arr i)) in
    let cal = Int64.add (snd (Array.get arr i))
        (if (i=len-1) then 0L else (snd (Array.get arr_r (i+1))) ) in

    let d_sub = if (i=len-1) then 0L else (fst (Array.get arr_r (i+1))) in
    let d_sub = Int64.sub distance d_sub in
    let cal = Int64.sub cal d_sub in

    if (cal > !t) 
    then (t := cal)
    else ();
    Array.set arr_r i (distance, cal)
  done;

  for i = 0 to (len-1) do
    for j = 0 to (len-1) do
      let cal =
        if i >= j then 0L
        else
          let d_l = fst (Array.get arr_l i) in
          let d_r = fst (Array.get arr_r j) in
          let d_sub = if d_l > d_r then d_r else d_l in

          let cal_l = snd (Array.get arr_l i) in
          let cal_r = snd (Array.get arr_r j) in
          let cal = Int64.sub (Int64.add cal_l cal_r) d_sub in
          cal
      in

      if (cal > !t) 
      then (t := cal)
      else ()
    done;
  done;

  Printf.printf "%Ld" !t;