program abc168C
    implicit none

    integer(8) :: a, b
    real(8) :: h, m
    real(8), parameter :: pi = 3.141592653589_8
    real(8) :: int1, int2, realp
    read(*,*) a, b, h, m
    
    int1 = real(a**2+b**2, kind=8)
    int2 = real(2*a*b, kind=8)
    realp = cos((h/6-m/30+m/360)*pi)

    write(*,*) sqrt(int1-int2*realp)

    stop
end program abc168C