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

#define PI       3.1415926535
#define SITA(c)  ((PI * (c)) / 180.0)


int main()
{
    int a,b,h,m;
    double ans, double_ans = 0;
    int l_dir, s_dir;
    double d;
    double fValC;

    // 整数の入力
    scanf("%d %d %d %d", &a, &b, &h, &m);
    //針の進んだ角度
    l_dir = 360/12*h + (double) m * 360/12/60;
    s_dir = 360/60*m;
    //余弦定理
    if (l_dir > s_dir)
    {
        d = (double)l_dir - (double)s_dir;
    }
    else
    {
        d = (double)s_dir - (double)l_dir;
    }
printf("a=%d, b=%d, h=%d, m=%d, s_dir=%d, l_dir=%d, d=%f\n", a, b, h, m, s_dir, l_dir, d);
    double_ans = a*a + b*b -2*a*b*cos(SITA(d));
printf("cos=%f,double_ans=%f\n", cos(SITA(d)),double_ans);
    ans = sqrt(double_ans);

    // 出力
    printf("%f",ans);
    return 0;
}
