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

int main(void)
{
    int A, B, M, H;
    long double H_a, M_a, angle, ans; 

    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &H);
    scanf("%d", &M);

    H_a = M*0.5*(M_PI/180) + H*30*(M_PI/180);
    M_a = M*6.0 * (M_PI/180);

    angle = H_a - M_a;

    ans = sqrt(A*A + B*B - 2*A*B*cos(angle));

    printf("%.10Lf\n", ans);

    return 0;
}