defmodule Main do def same_number_count(a, b, c, d) do n1 = max(a, c) n2 = min(b, d) max(0, n2 - n1 + 1) end def solve(a, b, c, d) do (b - a + 1) * (d - c + 1) - same_number_count(a, b, c, d) end def main do [a, b, c, d] = IO.gets("") |> String.trim |> String.split |> Enum.map(&String.to_integer/1) solve(a, b, c, d) |> IO.puts end end