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

// use M_PI

int main(void) {
    
    long A,B,H,M;
    scanf("%ld %ld %ld %ld",&A,&B,&H,&M);

    // jishin
    long double Arad = ((H*30.0) + (M/2.0)) * M_PI/180.0;
    long double Brad = M * 6.0 * M_PI/180.0;

    long double res = sqrtl(((A * sin(Arad) - B * sin(Brad)) *  (A * sin(Arad) - B * sin(Brad))) + ((A * cos(Arad) - B * cos(Brad)) * (A * cos(Arad) - B * cos(Brad))));
    printf("%.10Lf\n",res);

    return 0;
}