open System

let sqrt (x : decimal) : decimal =
    let rec f x y =
        let v = y + x / y 
        let z = v / decimal 2
        if abs (y - z) <= Decimal.Zero then 
            y 
        else 
            f x z 
    f x x 

let f (a: float) (b: float) (h: float) (m: float): decimal =
    let large =
        let minutes = 60. * h + m 
        let rate = minutes / (60. * 12.) 
        let rad = 2. * Math.PI * rate 
        let x = decimal a * (decimal <| cos rad)
        let y = decimal a * (decimal <| sin rad )
        (x, y)
    let small = 
        let rate = m / 60. 
        let rad = 2.0 * Math.PI * rate 
        let x = decimal b * (decimal <| cos rad) 
        let y = decimal b * (decimal <| 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"
