Scanf.scanf "%s" (fun s ->
    let n = String.length s in
    let rec loop i a b =
        if i = n then min a b * 2 else
            if s.[i] = '0' then loop (i + 1) (a + 1) b
                           else loop (i + 1) a (b + 1)
    in
    loop 0 0 0 |> Printf.printf "%d\n"
)