let (a, b, h, m) = Scanf.sscanf (read_line ()) "%d %d %d %d" @@ fun a b h m -> (a, b, h, m)

let pi = 3.14159265358

let () =
  let t = 2. *. (float h /. 12. +. float m /. 60. /.12.) in
  let s = 2. *. (float m /. 60.) in
  let diff = ref (t -. s) in
  if !diff < 0. then diff := -1. *. !diff;
  let c2 = (float @@ a * a) +. (float @@ b * b) -. (float @@ 2 * a * b) *. cos (!diff *. pi) in
  print_float @@ sqrt c2;
