#include <stdio.h> 
#include <math.h>
#define pi 3.14159265358979323846
int main() {
  double a,b,h,m;
  scanf("%lf",&a);
  scanf("%lf",&b);
  scanf("%lf",&h);
  scanf("%lf",&m);
  long double theta = fabsl(h*120-23*m)*pi/72;
  long double L;
  if (theta<=pi) L = sqrt(a*a+b*b-2*a*b*cos(theta));
  else L = sqrt(a*a+b*b+2*a*b*cos(theta));
  printf("%.10Lf\n",L);
  return 0;
}