let read_floats () =
  let str = read_line() in
  List.map (fun x -> float_of_string x) (Str.split (Str.regexp " +") str)
;;

let input = read_floats() in
let a = List.nth input 0 in
let b = List.nth input 1 in
let h = List.nth input 2 in
let m = List.nth input 3 in
let pi = acos (-1.) in
let x1 = a *. cos (h /. 12. *. 2. *. pi +. m /. 720. *. 2. *. pi) in
let y1 = a *. sin (h /. 12. *. 2. *. pi +. m /. 720. *. 2. *. pi) in
let x2 = b *. cos (m /. 60. *. 2. *. pi) in
let y2 = b *. sin (m /. 60. *. 2. *. pi) in
let sqx = (x1 -. x2) *. (x1 -. x2) in
let sqy = (y1 -. y2) *. (y1 -. y2) in
print_endline (string_of_float (sqrt (sqx +. sqy)))
