import Foundation

func readFourInts(separator: String.Element = " ") -> (a: Int, b: Int, c: Int, d: Int) {
    let ints = readLine()!.split(separator: separator).map { Int($0)! }
    return (a: ints[0], b: ints[1], c: ints[2], d: ints[3])
}

func mainC() {
    let (A, B, H, M) = readFourInts()

    let times = H * 60 + M
    let Adgree = (Double(times) * 0.5).truncatingRemainder(dividingBy: 360)
    let Bdgree = (Double(times) * 6).truncatingRemainder(dividingBy: 360)

    let diff = abs(Adgree - Bdgree) > 180 ? abs(Adgree - Bdgree) - 180 : abs(Adgree - Bdgree)

    let result = Double(A * A + B * B) - 2 * Double(A * B) * cos(diff * Double.pi / 180)
    print(result.squareRoot())
}
mainC()