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

#define PI 3.1415926535897946264338327950288419716939937510L

int main(void)
{
    int A, B, H, M;
    long double theta, ans;
    scanf("%d %d %d %d", &A, &B, &H, &M);
    theta = 2 * PI * ((long double)H / 12.0L + ((long double)M / 60.0L) / 12.0L - (long double)M / 60.0L);
    ans = sqrtl((long double)(A * A + B * B) - 2 * (long double)(A * B) * cosl(theta));
    printf("%20.20Lf\n", ans);
    return 0;
}