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

int main(void){
  double a,b,h,m;
  double c,t;
  
  scanf("%lf %lf %lf %lf", &a, &b, &h, &m);
  
  h=30.0*h + 0.5*m;
  m=6.0*m;
  
  t=fabs(m-h);
  t=t*(3.14159265358979/180.0);
  
  c=sqrt(a*a+b*b - 2*a*b*cos(t));
         
  printf("%.12lf", c);
  
  return 0;
}