/*ex4_2
 Sweet_Sweet_Soul */

#include <stdio.h>
#include <math.h>
#define PI 3.141592653589

int main(void) {
    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桁出力*/
    return 0;
}
