#include<stdio.h>
#include<math.h>
int main(){
  double w,ans,h,m,a,b;
  scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
  w=fabs(180/6.0*h+180/360.0*m-180/30.0*m);
  if(w==180.0){
    ans=a+b;
    printf("%lf",ans);
    return 0;
  }
  else{
    if(w>180.0)w=2.0-w;
    ans=sqrt(a*a+b*b-2.0*a*b*cos(w/180.0*M_PI));
    printf("%lf",ans);
    return 0;
  }
}
