import Foundation

struct Vec2 {
    var x:Double;
    var y:Double;
}

func Distance(a:Vec2, b:Vec2)->Double {
    let v = Vec2(x:a.x - b.x, y:a.y - b.y)
    return sqrt(v.x * v.x + v.y * v.y)
}

func CalcHVec(h:Double, m:Double, length:Double) -> Vec2 {
    let pi2 = Double.pi * 2.0
    let hrad = pi2 * h / 12.0
    let mrad = (pi2 / 12.0) * m / 60.0

    return Vec2(x:cos(hrad + mrad) * length, y:sin(hrad + mrad) * length)
}

func CalcMVec(m:Double, length:Double) -> Vec2 {
    let pi2 = Double.pi * 2.0
    let mrad = pi2 * m / 60.0

    return Vec2(x:cos(mrad) * length, y:sin(mrad) * length)
}

let args = readLine()?.split(separator: " ") ?? []

let a = Double(args[0]) ?? 0  // 時針長さ
let b = Double(args[1]) ?? 0  // 分針長さ
let h = Double(args[2]) ?? 0
let m = Double(args[3]) ?? 0

let hvec = CalcHVec(h: h, m: m, length: a)
let mvec = CalcMVec(m: m, length: b)
let result = Distance(a: hvec, b: mvec)

print(SIMD2<Double>(hvec.x, hvec.y))

print(result)