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

int main (){

  double A = 0, B = 0, H = 0, M = 0;
  scanf("%lf %lf %lf %lf", &A, &B, &H, &M);

  double lad_h = 0, lad_m = 0;
  lad_m = 2 * M_PI * ( M / 60 );
  lad_h = 2 * M_PI * ( H / 12 ) + 2 * M_PI * ( M / 60 ) / 12;

  double lad;
  if ( lad_m >= lad_h ){
    lad = lad_m - lad_h;
  }
  else{
    lad = lad_h - lad_m;
  }

  double res = 0;
  res = A*A + B*B - 2*A*B * cos(lad);
  res = sqrt(res);

  printf("%.10lf \n", res);

  return 0;
}