import Foundation

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

let rad = (H * 60  + M) * 5.5 / 180.0 * Double.pi
let C = A * A + B * B - (2 * A * B * cos(rad))
print(sqrt(C))