#include<stdio.h>
#include<math.h>
#define _USE_MATH_DEFINES
int main(){
  int unused __attribute__((unused));
  int A, B, H, M;
  long double rad, rsq;
  unused = scanf("%d %d %d %d", &A, &B, &H, &M);

  rad = 2*M_PI*((long double)H/12.0 + ((long double)M/60.0)/12.0 - (long double)M/60.0);
  rsq = (long double)(A*A + B*B) - (long double)(2*A*B)*cosl(rad);
  printf("%20.20Lf", sqrtl(rsq));
  return 0;
}