const main = arg => {
  const [a, b, h, m] = arg.trim().split('\n')[0].split(' ').map(x => Number(x));
  const minuteDeg = m / 60;
  const hourDeg = (h / 12 + m / 720);
  console.log(Math.sqrt(a ** 2 + b ** 2 - 2 * a * b * Math.cos(Math.abs(minuteDeg - hourDeg) * 2 * Math.PI)));
};

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