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

int main(void){
  int a,b,h,m;
  long double t1,t2,r,rr,answer;
  scanf("%d %d %d %d", &a, &b, &h, &m);
  t1 = h * 360 / 12;
  t1 += m * 30 /60;
  t2 = m * 360 / 60;
  r = fabs(t1 - t2);
  if(r > 180)
    r = 360 - r;
  rr = cosl(r * M_PI / 180);
  answer = sqrtl(a*a + b*b - 2*a*b*rr);
  printf("%.15llf", answer);
  return 0;
}