open System

let a, b, h, m = stdin.ReadLine().Split() |> fun [| a; b; h; m; |] ->a, b, h, m

/// HMを用い角度を求める
let angle h m =
    let hm = float h + float m / 60.0
    2.0 * Math.PI * hm * (1.0 - 1.0 / 12.0)

/// 余弦定理を用いた長さの計算
let length a b angle =
    a * a + b * b - 2.0 * a * b * Math.Cos(angle) |> Math.Sqrt 
    
angle (float h) (float m) |> length (float a) (float b) |> stdout.WriteLine 