let eat x lst = 
	let rec impl x lst times = match lst with
		| a::b::xs -> if a + b > x
						then impl x (a::(b-1):: xs) (times + 1)
						else impl x (b::xs) times
		| a::xs -> times
		| [] -> times
	in
		impl x lst 0

let _ =
	let f = Scanf.scanf "%d %d\n" (fun x y -> eat y) in
	read_line () |> Str.split (Str.regexp " ") |> List.map(fun x -> int_of_string x)|> f |> Printf.printf "%d"
