function main(arg) {
  const array = arg.trim().split(" ");
  const A = parseInt(array[0]);
  const B = parseInt(array[1]);
  const H = parseInt(array[2]);
  const M = parseInt(array[3]);
  const PI = Math.PI;

  const th = ((H * 60 + M) / 720) * 2 * PI;
  const tm = (M / 60) * 2 * PI;

  let xh = A * Math.cos(th);
  let yh = A * Math.sin(th);
  let xm = B * Math.cos(tm);
  let ym = B * Math.sin(tm);
  let dx = xh - xm;
  let dy = yh - ym;

  let result = Math.sqrt(dx * dx + dy * dy);

  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
// main("3 4 10 40");
