Imports System

Module Module1

    Sub Main()

        Dim ABHM() As Integer = Console.ReadLine().Split(" ").Select(Function(x) Integer.Parse(x)).ToArray()

        Dim jkaku As Double = ABHM(2) * 30 + ABHM(3) * 0.5
        Dim fkaku As Double = ABHM(3) * 6
        Dim kaku As Double

        If jkaku - fkaku <= 180 Then
            kaku = Math.Abs(jkaku - fkaku)
        Else
            kaku = 360 - Math.Abs(jkaku - fkaku)
        End If

        Dim yogen As Double = Math.Sqrt(ABHM(0) ^ 2 + ABHM(1) ^ 2 - 2 * ABHM(0) * ABHM(1) * Math.Cos(kaku * Math.PI / 180))

        Console.WriteLine(yogen)

    End Sub

End Module