(args => {
  const [A,B,H,M] = args.trim().split(' ').map(parseFloat);
  const theta = ( (H+M/60)/12.0 - M/60.0 ) * Math.PI * 2.0;
  const CC = A*A + B*B - 2.0*A*B*Math.cos(theta);
  console.log((Math.sqrt(CC)).toString());
})(require('fs').readFileSync('/dev/stdin', 'utf8'))