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

int main(){
  double a,b,h,m,dif;
  scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
  dif=M_PI*(m/30-(h*60+m)/360);
  printf("%.10lf",sqrt(a*a+b*b-a*b*cos(dif)*2));
  return(0);
}