open System type Sol() = member this.Solve() = let A = stdin.ReadLine().Split() |> Array.map int let B = stdin.ReadLine().Split() |> Array.map int let [|C;D|] = stdin.ReadLine().Split() |> Array.map int let rmB = if C > A.[1] then A.[1] else C let rmW = (C - rmB) A.[0] <- A.[0] - rmW A.[1] <- A.[1] - rmB B.[0] <- B.[0] + rmW B.[1] <- B.[1] + rmB let rmW = if D > B.[0] then B.[0] else D let rmB = (D - rmW) B.[0] <- B.[0] - rmW B.[1] <- B.[1] - rmB A.[0] <- A.[0] + rmW A.[1] <- A.[1] + rmB printfn "%d" A.[0] let mySol = new Sol() mySol.Solve()