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