import Foundation

func readDoble() -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func main() {
    let abhm = readDoble()
    let (a, b, h, m) = (abhm[0], abhm[1], abhm[2],abhm[3])
    
    let alpha = (h * 60 + m) / 720 * (Double.pi * 2)
    let beta  = m / 60 * (Double.pi * 2)
    let theta = alpha - beta
    
    let sqAns = pow(a, 2.0) + pow(b, 2.0) - 2.0 * a * b * cos(theta)
    print(sqAns.squareRoot())
    
}
main()
