program main
      implicit none
      integer :: a, b, h, m
      real(16) :: a2, b2, rad, c

      read *, a, b, h, m

      a2 = real(a)
      b2 = real(b)
      rad = abs( 0.5*(real(h)*60+m) - 6*m )
      rad = 3.141592653589793238462643383279*rad / 180.0

      c = a2**2 + b2**2 - 2*a2*b2*cos(rad)

      print *, sqrt(c)

end program main
