open System

let s = stdin.ReadLine().Split() |> Array.map(float)
let a = s.[0]
let b = s.[1]
let h = s.[2]
let m = s.[3]

let thetaH = 2.0 * Math.PI * (h + m / 60.0) / 12.0
let thetaM = 2.0 * Math.PI * m / 60.0

let result = Math.Sqrt(a*a+b*b - 2.0*a*b*Math.Cos(thetaH-thetaM))
printfn "%.10f" result
