Option Explicit On

Module Module1

    Sub Main()

        Dim tmp As String() = Split(Console.ReadLine(), " ")
        Dim A As Integer = CInt(tmp(0))
        Dim B As Integer = CInt(tmp(1))
        Dim H As Integer = CInt(tmp(2))
        Dim M As Integer = CInt(tmp(3))

        Dim jkaku As Double = H * 30 + M * 0.5
        Dim fkaku As Double = M * 6
        Dim kaku As Double

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

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

        Console.WriteLine(yogen)

    End Sub

End Module
