// : (Colon) 

import Foundation

func main() {
    let i = readLine()!.split(separator: " ").map{Double($0)!}
        
    let (a,b,h,m) = (i[0], i[1], i[2], i[3])
    let pi = Double.pi
    // それぞれの針の角度
    let x = 2 * pi * (h * 60 + m) / (60 * 12)
    let y = 2 * pi * (m) / (60)

    let (ax, ay) = (a * cos(x), a * sin(x))
    let (bx, by) = (b * cos(y), b * sin(y))
    
    let distance = pow(pow(ax - bx, 2) + pow(ay - by, 2), 0.5)
    print(distance)
}

main()