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

int main(void){

    int A, B, H, M;

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

    long double short_v = 360.0 / (12*60);
    long double long_v = 60.0;

    long double short_arg = (short_v * (H * 60) + short_v * M);
    long double long_arg = long_v * M;

    long double theta = (short_arg - long_arg);
    if (theta < 0) {
        theta = theta*(-1);
    }
    theta = (theta*PI)/180.0;
    long double tmp = cos(theta);

    long double result = A*A + B*B - 2*A*B*tmp;

    result = sqrtl(result);

    printf("%Lf", result);

    return 1;
}