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

#define PI 3.141592653589793

int main() {
  char buf[1500];
  int a,b,h,m;
  while(fgets(buf,sizeof(buf),stdin)!=NULL) {
    sscanf(buf,"%d %d %d %d", &a,&b,&h,&m);
  }
  long double rad, x;
  rad = 2 * PI *(((long double)h+(long double)m/60)/12 - (long double)m/60);

  x = sqrtl((long double)(a*a+b*b)-2*(long double)a*(long double)b*cosl(rad));

  printf("%.20Lf\n",x);
  return 0;
}
