#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(1/6*h+1/360*m-1/30*m);
  if(w>1)w--;
  ans=sqrt(a*a+b*b-2*a*b*cos(w*M_PI));
  printf("%lf",ans);
  return 0;
}
