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

int main(void){
  double a,b,h,m,t1,t2,ans;
  scanf("%lf",&a);
  scanf("%lf",&b);
  scanf("%lf",&h);
  scanf("%lf",&m);
  t2=M_PI*m/30.0;
  t1=M_PI*h/6.0+t2/12.0;
  ans=(a*sin(t1)-b*sin(t2))*(a*sin(t1)-b*sin(t2))+(a*cos(t1)-b*cos(t2))*(a*cos(t1)-b*cos(t2));
  ans=sqrt(ans);
  printf("%.9lf",ans);
  return 0;
}
  