open System

let f (a: float) (b: float) (h: float) (m: float): float =
    let large =
        let minutes = 60. * h + m 
        let rate = minutes / (60. * 12.) 
        let rad = 2. * Math.PI * rate 
        let x = a * cos rad
        let y = a * sin rad 
        (x, y)
    let small = 
        let rate = m / 60.
        let rad = 2.0 * Math.PI * rate 
        let x = b * cos rad 
        let y = b * sin rad 
        (x, y)
    let x = fst large - fst small |> abs 
    let y = snd large - snd small |> abs 
    pown x 2 + pown y 2
    |> sqrt

let l = Console.ReadLine().Split()|> Array.map float 
f l.[0] l.[1] l.[2] l.[3]
|> printfn "%f"
