#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){
int a,b,h,m;
double hkaku,mkaku;
double dif;
double ans;
scanf("%d %d %d %d",&a,&b,&h,&m);

mkaku=(double)6.0*m;
hkaku=(double)30*h+0.5*m;
dif=abs(mkaku-hkaku);
if(dif>=180){dif=abs(180-dif);}
ans=(double)(a*a)+(double)(b*b)-(double)(2.0*a*b*cos(dif*3.14159265358979/180));
double ans2=sqrt(ans);
//printf("%lf %lf %lf %.100lf %.100lf",mkaku,hkaku,dif,ans,ans2);
printf("%.50lf",ans2);
}
