function main(input) {
  let [a,b,h,m] = input[0].trim().split(" ").map(i => parseInt(i));
  const p = [(h*5*6)+30/60*m,m*6];
  const diff = Math.max(...p)-Math.min(...p);
  const rad = Math.min(diff, 360-diff) * Math.PI / 180;
  const cosine = Math.cos(rad);
  const result = a*a + b*b - (2*a*b*cosine);
  console.log(Math.sqrt(result));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));