open System let solve a b c d = let cdSet = [c .. d] |> Set.ofList let cdSetSize = d - c + 1 let cnts = [a .. b] |> Seq.countBy(fun x -> Set.contains x cdSet) let getCount flag = Seq.tryFind(fun (k, _) -> k = flag) >> Option.map snd >> Option.defaultValue 0 let t1 = cnts |> getCount false let t2 = cnts |> getCount true cdSetSize * t1 + (cdSetSize - 1) * t2 let a, b, c, d = let t = Console.ReadLine().Split() |> Array.map int t.[0], t.[1], t.[2], t.[3] solve a b c d |> Console.WriteLine