import Foundation

let line = readLine()!.components(separatedBy: " ")

let A = Float(line[0])!
let B = Float(line[1])!
let H = Float(line[2])!
let M = Float(line[3])!

let T = H * 60.0 + M

let a = T / 720.0 * 360 * Float.pi / 180.0
let b = M / 60.0 * 360 * Float.pi / 180.0

let ax = A * sin(a)
let ay = A * cos(a)
let bx = B * sin(b)
let by = B * cos(b)
let distance = sqrt(pow(ax - bx, 2) + pow(ay - by, 2))
print(distance)
