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

int main(void) {
  double a,b,h,m,k,l,y;
  scanf("%lf %lf %lf %lf",&a,&b,&h,&m );
h=h/12;
m=m/60;
k=h-m;
l=k*2*3.141592653589;
l=cos(l);
y=(a*a)+(b*b)-(2*a*b*l);
  y=sqrt(y);
  printf("%lf",y);
  return 0;
}
