import Foundation

let abhm = readLine()!.split(separator: " ").map { Double($0)! }
let (a, b, h, m) = (abhm[0], abhm[1], abhm[2], abhm[3])

let hour = h + m / 60
let angle = hour * 11 * Double.pi / 6
let squaredResult = a * a + b * b - 2 * a * b * cos(angle)

print(squaredResult.squareRoot())
