type Bag = { WhiteStone: int BlackStone: int } let solve a b c d = let c_b = min a.BlackStone c let c_w = c - c_b let a' = { WhiteStone = a.WhiteStone - c_w; BlackStone = a.BlackStone - c_b } let b' = { WhiteStone = b.WhiteStone + c_w; BlackStone = b.BlackStone + c_b } let d_w = min b'.WhiteStone d let d_b = d - d_w // let a'' = { WhiteStone = a'.WhiteStone + d_w; BlackStone = a'.BlackStone + d_b } // let b'' ... a'.WhiteStone + d_w let R() = stdin.ReadLine().Split() |> Array.map int let A = let t = R() { WhiteStone = t.[0]; BlackStone = t.[1] } let B = let t = R() { WhiteStone = t.[0]; BlackStone = t.[1] } let C, D = let t = R() t.[0], t.[1] solve A B C D |> stdout.WriteLine