let pi = atan 1. *. 4.

let () = Scanf.scanf "%f %f %f %f" @@ fun l1 l2 h m ->
  let a = 0.5 *. (60.0 *. h +. m) in
  let b = 6.0 *. m in
  let theta = if (a -. b) >= 0. then a -. b else b -. a in
  let th = if theta <= 180. then theta else 360. -. theta in
  let rad = th *. pi /. 180. in
  let c2 = l1 *. l1 +. l2 *. l2 -. 2.0 *. (cos rad) *. l1 *. l2 in
  Printf.printf "%.15f\n" @@ sqrt c2