function Main(input) {
  var tmp = input.split(" ");
  var A = parseInt(tmp[0]);
  var B = parseInt(tmp[1]);
  var H = parseInt(tmp[2]);
  var M = parseInt(tmp[3]);

  var deg = (5.5 * (H * 60 + M)) % 360;
  var cosdeg = Math.cos(deg * (Math.PI / 180));
　
  var result = Math.sqrt(A * A + B * B - 2 * A * B * cosdeg);
  console.log(result);
}

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