Imports System

Public Class Program


    Public Shared Sub Main(args As String())

        Dim Input() As Decimal = Array.ConvertAll(Of String, Decimal)(Console.ReadLine.Split, AddressOf Decimal.Parse)

        Dim HAngle As Decimal = Math.PI / 6 * (Input(2) + Input(3) / 60)
        Dim MAngle As Decimal = Math.PI / 30 * Input(3)

        Dim TH As Decimal = Math.Abs(HAngle - MAngle)

        Console.WriteLine(Math.Sqrt(Input(0) ^ 2 + Input(1) ^ 2 - 2 * Input(0) * Input(1) * Math.Cos(TH)))



    End Sub




End Class