func main() var aw: int :: cui@inputInt() var ab: int :: cui@inputInt() var bw: int :: cui@inputInt() var bb: int :: cui@inputInt() var c: int :: cui@inputInt() var d: int :: cui@inputInt() if(c <= ab) do ab :- c do bb :+ c else var cw: int :: c - ab var cb: int :: ab do aw :- cw do ab :- cb do bw :+ cw do bb :+ cb end if var ans: int :: aw + [d, bw].min() do cui@print("\{ans}\n") end func