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

int main()
{

    double a,b,h,m;
    scanf("%lf", &a);
    scanf("%lf", &b);
    scanf("%lf", &h);
    scanf("%lf", &m);
    double big = 0;
    double small = 0;//動きが。。

    big = 2.0 * M_PI * m / 60.0;
    small = 2.0 * M_PI * (h * 60 + m) / (60 * 12); //分で計算

    double ans = sqrt(a * a + b * b - 2 * a * b * cos(small - big));
   
    printf("%.13f", ans);
        
    printf("\n");
}