defmodule Main do def main do IO.gets("") |> String.split() |> Enum.map(&String.to_integer(&1)) |> (fn [a, b, c, d] -> cond do a > c -> [c, d, a, b] true -> [a, b, c, d] end end).() |> (fn [a, b, c, d] -> (b - a + 1) * (d - c + 1) - cond do b < c -> 0 true -> min(b, d) - c + 1 end end).() |> IO.puts() end end