function main(input){

  let [A, B, H, M] = input.split(' ').map(Number);

  const minute = H*60 + M;

  const theata =  (11*minute) / 360 * Math.PI

  const a  = Math.sqrt(A*A + B*B - 2*A*B*Math.cos(theata));

  console.log(a);

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