open System
 
let flip f a b = f b a
let read() = Console.ReadLine()
let pi = Math.PI
let pi2 = pi * 2.0
 
[<EntryPoint>]
let main _ =
    let str = read().Split(' ')
    let a = float str.[0]
    let b = float str.[1]
    let h = float str.[2]
    let m = float str.[3]
    
    let rad = (h / 12.0 + m / 60.0) / 12.0 - m / 60.0 * pi2
    
    let len = sqrt(a * a + b * b - 2.0 * a * b * cos(rad))
    
    printfn "%f" len
    
    0 