Scanf.scanf "%d %d %d %d %d %d %d" (fun ai ao at aj al as_ az ->
    let k = ao in
    let f a = if a = 0 then 0 else 2 - a mod 2 in
    let v =
        match f ai * f aj * f al with
        | 1 | 2 -> 1
        | _ -> 0
    in

    let k = k + v * 3 in
    let ai = ai - v in
    let aj = aj - v in
    let al = al - v in
    let k = k + (ai / 2) * 2 in
    let k = k + (aj / 2) * 2 in
    let k = k + (al / 2) * 2 in
    Printf.printf "%d\n" k
)