function main(lines) {
  const [A, B, H, M] = splitN(lines[0]);

  const
    hR = H / 6 * Math.PI,
    mR = M / 30 * Math.PI,
    r = Math.max(hR, mR) - Math.min(hR, mR),
    res = Math.sqrt( (A ** 2) + (B ** 2) - (2*A*B*Math.cos(r)) );
  
  console.log(res);
}


main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );



function splitN(s) {
  return s.split(' ').map(Number);
}