const Main = ipt => {
  const [ A, B, H, M ] = ipt.split(' ').map(e => Number(e));

  const omega_A = Math.PI * H / 6;
  const omega_B = Math.PI * M / 30;

  let theta = Math.abs(omega_A - omega_B);
  //console.log('theta: ', theta)
  if(theta > Math.PI)  theta = theta - Math.PI;

  //console.log('theta: ', theta)

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

  console.log(x)
};

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

//Main(`3 4 9 0`)
//Main(`3 4 10 40`)
