import Foundation

func f(A: Int, B: Int, H: Int, M: Int) -> Double {
    // A: cm
    // B: cm
    // H: 時
    // M: 分
    let h: Double = ((Double(H) + (Double(M)/60)) / 12 * 360).truncatingRemainder(dividingBy: 360) * Double.pi / 180
    let m: Double = (( Double(H)*60 + Double(M)) / 60 * 360).truncatingRemainder(dividingBy: 360) * Double.pi / 180
    let c: Double = sqrt( ((pow(Decimal(A), 2) + pow(Decimal(B), 2)) as NSDecimalNumber).doubleValue - Double(2*A*B) * cos(  abs(h - m) ) )
    return c
}

let input = readLine()!.components(separatedBy: " ").map{ Int($0)! }
print( f(A: input[0], B: input[1], H: input[2], M: input[3]) )