const Main = ipt => {
  const [ A, B, H, M ] = ipt.split(' ').map(e => Number(e));
  const omega_A = (H + (M / 60.0)) / 6.0;
  const omega_B = M / 30.0;

  let theta = Math.abs(omega_A - omega_B);
  if(theta > 1)  theta = theta - 1;

  const x = Math.sqrt( Math.pow(A,2.0) + Math.pow(B,2.0) - 2.0*A*B*Math.cos(Math.PI * theta) );

  console.log(x)
};

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