Imports System

Module Program
 
    Sub Main(args As String())
        Dim iInput As String() = Split(Console.ReadLine(), " ")
        Dim iA As Integer = Integer.Parse(iInput(0))
        Dim iB As Integer = Integer.Parse(iInput(1))
        Dim iH As Double = Integer.Parse(iInput(2))
        Dim iM As Double = Integer.Parse(iInput(3))

        Dim rad As Double = Math.PI * 2 * ((iH / 12) + (iM / 720) - (iM / 60))

        Dim sq As Double = (iA ^ 2 + iB ^ 2) - (2 * iA * iB) + Math.Cos(rad)


        Console.WriteLine(Math.Sqrt(sq))


    End Sub
End Module
