open Printf
open Scanf

let solve a b h m =
  let pi = 4.0 *. atan 1.0 in
  let tm = pi *. m /. 30.0 in
  let th = pi *. (h /. 6.0 +. m /. 360.0) in
  sqrt @@ a *. a +. b *. b -. 2.0 *. a *. b *. cos (tm -. th)

let () =
  scanf "%f %f %f %f " solve |> printf "%.10f\n"
