program main

  implicit none
  real(8) :: a,b,h,m
  real(8), parameter :: pi = 4.0d0*atan(1.0d0)
  real(8) :: t1,t2,c
  read(*,*) a,b,h,m

  t1 = pi/6.0d0*h
  t2 = pi/30.0d0*m
  t2 = max(t1,t2)-min(t1,t2)
  
  c = sqrt(a**2 + b**2 -2.0d0*a*b*cos(t2))
  write(*,*) c

end program main