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

int main()
{
  double A, B, H, M, min, time, dif;
  double ans2, ans;
  scanf("%lf", &A);
  scanf("%lf", &B);
  scanf("%lf", &H);
  scanf("%lf", &M);

  min = 360.0 * M / 60.0;
  time = 360.0 * (H / 12.0 + M / (60.0 * 12.0));

  dif = fabs(min - time);

  if(dif > 180.0){
    dif = 360.0 - dif;
  }

  ans2 = A*A + B*B - 2.0*A*B*cos(dif/180.0*M_PI);
  ans = sqrt(ans2);

  printf("%.10f\n", ans);

  return 0;
  }
