#include <stdio.h>
#include <math.h>
#define PI 3.1415926535897932384626433

int main(void)
{
  double a,b,h,m;
  scanf("%lf %lf %lf %lf", &a, &b, &h, &m);

  double tl, ts;

  tl = m*6;
  ts = (h+m/60)*30;

  double ang;
  ang = tl-ts;
  if(ang>180) ang *= -1;
  else if(ang<0) ang += 360;

  double l=a*a+b*b-2*a*b*cos(ang*2*PI/360.0);
  //printf("ang = lf\n", ang );
  printf("%.20lf", sqrt(l));
  return 0;
}



  