// parameter "input" gets all data
function Main(input) {
   // the first line is assigned to input[0], the second line is assigned to input[1] similarly.
    input = input.split("\n");
    // convert string from integer using "parseInt"
    let tmp = input[0].split(' ')

   const [a,b,h,m]=tmp
   let hangle=  (30*Number(h)+30*((m/60).toFixed(15)))*Math.PI/180
   let mangle =  6*Number(m)*Math.PI/180
   let ax= Number(a)*Math.sin(hangle).toFixed(20)
   let ay= Number(a)*Math.cos(hangle).toFixed(20)

   let bx= Number(b)*Math.sin(mangle).toFixed(20)
   let by= Number(b)*Math.cos(mangle).toFixed(20)
   let cx=bx-ax
   let cy=by-ay
   let ans=cx*cx+cy*cy
   console.log(Math.sqrt(ans))

}
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
