/*ex4_2
 S_S_S */

#include <stdio.h>
#include <math.h>

int main(void) {
    double pi=3.141592653589;
    double h_hand,m_hand,hour,minute;
    scanf("%lf",&h_hand);
    scanf("%lf",&m_hand);
    scanf("%lf",&hour);
    scanf("%lf",&minute);
    double h_arg=(pi*hour/6)+(pi*minute/360);/*短針のテッペンからの回転度*/
    double m_arg=pi*minute/30;
    double arg=h_arg-m_arg;/*針のなす角*/
    double ans=m_hand*m_hand+h_hand*h_hand-2*m_hand*h_hand*cos(arg);/*A^2+B^2-2ABcosθ*/
    ans=sqrt(ans);/*余弦定理*/
    printf("%.10f\n",ans);/*下10桁出力*/
}