program ABC168_C
  double precision::A,B,H,M
  double precision::pi,radH,radM,rad,ans
  read(*,*)A,B,H,M
  pi=datan(1.0d0)*4.0d0
  radH=(3.0d1*H+5.0d-1*M)*pi/1.8d2
  radM=6.0q0*M*pi/1.8d2
  rad=dabs(radH-radM)
  ans=sqrt(A*A+B*B-2.0d0*A*B*dcos(rad))
  write(*,*)ans
end program ABC168_C