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

  var rad = 6;

  var Hrad = H * 5 * rad + (30 * M) / 60;
  var Mrad = M * rad;

  var A2 = Math.pow(A, 2);
  var B2 = Math.pow(B, 2);
  var cos = Math.cos((Hrad - Mrad) * (Math.PI / 180));
  var l = Math.sqrt(A2 + B2 - 2 * A * B * cos);
  console.log(l);
}

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