function Main(input){
  input = input.trim().split(' ').map(x=>parseFloat(x));
  var a = input[0];
  var b = input[1];
  var h = input[2];
  var m = input[3];
  var angle = ((h+m/60.0)/12.0 - m/60.0)*2.0*Math.PI;
  var cos = Math.cos(angle);
  var ans = Math.sqrt(a**2.0 + b**2.0 - 2.0*a*b*cos);
  console.log(ans);
}
  


Main(require("fs").readFileSync("/dev/stdin", "utf8"));