program main
      implicit none
      integer :: a, b, h, m
      !double precision :: a2, b2, h2, m2, rad, c, tmp
      real(8) :: a2, b2, h2, m2, rad, c, tmp

      read *, a, b, h, m

      a2 = a
      b2 = b
      h2 = h
      m2 = m
      rad = abs( 0.5d0*(h2*60.0d0+m2) - 6.0d0*m2 )/180d0
      rad = 3.141592653589793238462643383279d0*rad

      c = a2**2 + b2**2 - 2.0d0*a2*b2*dcos(rad)
      c = sqrt(c)

      print *, c

end program main
