defmodule Main do
  def main do
    [short, long, hour, minute] =
      IO.gets("") |> String.trim() |> String.split() |> Enum.map(&String.to_integer/1)

    hour_angle = calculate_hour_angle(hour, minute)
    minute_angle = calculate_minute_angle(minute)

    angle =
      (hour_angle - minute_angle)
      |> abs()

    rad = :math.pi() / 180

    if angle > 180 do
      (short * short + long * long - 2 * short * long * :math.cos((360 - angle) * rad))
      |> :math.sqrt()
      |> IO.puts()
    else
      (short * short + long * long - 2 * short * long * :math.cos(angle * rad))
      |> :math.sqrt()
      |> IO.puts()
    end
  end

  defp calculate_hour_angle(hour, minute) do
    30 * hour + 0.5 * minute
  end

  defp calculate_minute_angle(minute) do
    minute * 6
  end
end