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


int min(int a,int b){

    if(a>=b){return b;}
    return a;
}


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

mkaku=(double)6.0*m;
hkaku=(double)30*h+0.5*m;
dif=fabs(mkaku-hkaku);
dif=min(dif,360-dif);
dif=dif*3.141592653589793238462643388419/180.0;
ans=sqrt((double)(a*a)+(b*b)-(2.0*a*b*cos(dif)));
//printf("%lf %lf %lf %.100lf %.100lf",mkaku,hkaku,dif,ans,ans2);
printf("%.40lf",ans);
}
