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