Scanf.scanf "%d %d %d" (fun a b c ->
    let bc = min b c in
    let o = bc * 2 in
    let c = c - bc in
    let b = b - bc in

    let ac = min a c in
    let o = o + ac in
    let c = c - ac in
    let a = a - ac in
    let o = if c > 0 then o + 1 else o in
    let o = o + b in
    Printf.printf "%d\n" o
)