      PROGRAM Colon
      IMPLICIT NONE
      real(16),parameter :: pi=3.141592653589793238
      real(16) :: a,b,h,m, ans2
      real(16) :: angleA,angleB,angleSub
      
      
      read*,a,b,h,m
      
      h = h + m/real(60)
      
      
      angleA = h / real(12) * real(2) * pi
      angleB = m / real(60) * real(2) * pi
      
   !   print*,angleA,angleB,abs(angleA-angleB)
      
      angleSub = max(angleA,angleB) - min(angleA,angleB)
      angleSub = min( angleSub,real(2)*pi-angleSub )
  !    print*,angleSub
      
      ans2 = a*a + b*b - (real(2)*a*b*cos( angleSub ))
      print*,sqrt(ans2)
      
    !  print*,cos( angleSub )
      
      END PROGRAM