open System

let a, b, h, m =
    let l = Console.ReadLine().Split(' ') |> Array.map float
    l.[0], l.[1], l.[2], l.[3]

let l =
    let theta =
        let pi = Math.PI
        let t1 =
            let h = (int h) % 12 |> float
            ((60.0 * h + m) / (12.0 * 60.0)) * 2.0 * pi
        let t2 =
            (m / 60.0) * 2.0 * pi
        Math.Abs (t1 - t2)

    a * a + b * b - 2.0 * a * b * (Math.Cos theta)
    |> Math.Sqrt

l |> Console.WriteLine
