let pi = atan(1.) *. 4.
let () =
  Scanf.scanf "%f %f %f %f\n" @@ fun a b h m ->
  let d = mod_float (abs_float (h *. 30. -. m *. 5.5)) 180. in
  let ans = sqrt (a**2. +. b**2. -. 2.*.a*.b*.cos(d *. pi /. 180.)) in
  Printf.printf "%f\n" ans