import Foundation

let input = readLine()!.split(separator: " ").map { Double($0)! }
let A = input[0]
let B = input[1]
let H = input[2]
let M = input[3]

let angleH = 30 * H + 0.5 * M
let angleM = 6 * M
var angle = abs(angleH - angleM)
angle = min(angle, 360 - angle)

let result: Double = (A * A + B * B - 2 * A * B * cos(angle * Double.pi / 180)).squareRoot()
print(result)
