#include <stdio.h>
#include <math.h>
int main () {
  double A,B;
  int H,M;
  scanf("%lf %lf %d %d",&A,&B,&H,&M);
  printf("%lf",sqrt(A * A + B * B - 2 * A * B * cos(M_PI * 2 * (H/12 - M/60))));
  return 0;
}
