import Foundation

let PI: Double = 3.14159265358979323846
if let inp = readLine() {
  let s = inp.components(separatedBy: " ")
  if let fa: Double = Double(s[0])
    ,let fb: Double = Double(s[1])
    ,let fh: Double = Double(s[2])
    ,let fm: Double = Double(s[3]) {
    let dir: Double = fh/12.0 + (fm/60.0)/12.0 - fm/60.0
    let ra: Double =  PI * 2.0 * dir
    let rq: Double = (fa * fa + fb * fb) - 2.0 * fa * fb * cos(ra)
    print(sqrt(rq))
  }
}
