function main(input) {
  const inputData = input.replace(/\s*$/g, '').split(/\s+/).map(v => parseInt(v));
  const [a, b, h, m] = inputData;

  const hRad = (h + m / 60) * Math.PI / 6;
  const mRad = m * Math.PI / 30;
  const hDeg = h * 30;
  const mDeg = m * 6;

  const vecA = {
    x: a * Math.sin(hRad),
    y: a * Math.cos(hRad)
  };
  const vecB = {
    x: b * Math.sin(mRad),
    y: b * Math.cos(mRad)
  };

  const res = Math.sqrt((vecA.x - vecB.x) ** 2 + (vecA.y - vecB.y) ** 2);

  console.log(res);
}

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