import Foundation

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

let line = readArrayDouble()
let (A, B, H, M) = (line[0], line[1], line[2], line[3])
let degree = 5.5 * ((H * 60) + M)
print((A * A + B * B - 2 * A * B * cos(degree * Double.pi / 180)).squareRoot())
