function Main(input) {
  input = input.replace(/\n/g, ' ');
  input = input.split(" ");
  var A = input[0];
  var B = input[1];
  var C = input[2];
  var D = input[3];
  var ans  = 0;
  var Cdo  = (Math.PI*2/12)*C+(Math.PI*2/12)/60*D;
  var Ddo = (Math.PI*2/60)*D;
  var Sado  = Math.abs(Cdo-Ddo);
  if(Sado >Math.PI){Sado-=Math.PI;}
  var c = Math.pow(A,2) + Math.pow(B,2) - 2*A*B*Math.cos(Sado);
  ans = Math.sqrt(c);
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));