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 h = int h
        let t1 = ((60.0 * float (h % 12) + m) / (12.0 * 60.0)) * 2.0 * Math.PI
        let t2 = (m / 60.0) * 2.0 * Math.PI
        Math.Abs (t1 - t2)

    let l2 = a * a + b * b - 2.0 * a * b * (Math.Cos theta)

    Math.Sqrt(l2)

l |> Console.WriteLine