function main(input) {
  const args = input.split("\n");
  const [A, B, H, M] = args[0].split(" ").map((n) => parseInt(n, 10));

  const min = H * 60 + M;
  console.log(Math.sqrt(A * A + B * B - (2 * A * B * Math.cos(11 * Math.PI * min / 360))));
}

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