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 Sado  = (Math.PI*2)*Math.abs(C/12+D/720-D/60);
  if(Sado >Math.PI){Sado-=Math.PI;}
  var p = A*A+B*B;
  var q = 2*A*B;
  ans = Math.sqrt(p - q*Math.cos(Sado));
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));