let solve a b c x =
  let rec f acc i j k =
    if i > a then acc
    else if j > b then f acc (i+1) 0     0
    else if k > c then f acc i     (j+1) 0
    else f (acc + if 500*i + 100*j + 50*k = x then 1 else 0) i j (k+1)
  in f 0 0 0 0

let () = Scanf.scanf "%d %d %d %d" solve |> Printf.printf "%d\n"
