program main
    use,intrinsic :: iso_fortran_env
    implicit none
    real(real64):: a,b,h,m
    real(real64)x1,y1,x2,y2
    real(real64),parameter:: pi=acos(-1d0)
    read*, a,b,h,m
    h=(h+m/60)/12*2*pi
    m=m/60d0*2*pi
    

    x1 = a*cos(h)
    y1 = a*sin(h)
    x2 = b*cos(m)
    y2 = b*sin(m)
    print*, sqrt((x1-x2)**2 + (y1-y2)**2)
end program main