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

#define Pi 3.14159265358973284626

int main(void){
    double a,b,h,m;
    scanf("%lf %lf %lf %lf",&a,&b,&h,&m);

    long double kaku=(m/60-(h/12+m/720))*2*Pi;
    if(kaku<0){
        kaku*=-1;
    }
    long double kyuori2=a*a + b*b - 2*a*b*cos(kaku);
    printf("%-11Lf\n",sqrtl(kyuori2));

    return 0;
}
