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

let jisinKaku = h * 30 + m * 0.5
let hunsinKaku = m * 6
let kaku = min(360 - abs(jisinKaku - hunsinKaku), abs(jisinKaku - hunsinKaku))
let cosinus = cos(kaku * Double.pi / 180)
let ans = a * a + b * b - (2 * a * b * cosinus)
print(ans.squareRoot())