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

int main(void)
{
  long int a,b,h,m;
  scanf("%ld %ld %ld %ld", &a, &b, &h, &m);
  long double deg,c;
  deg = fabsl(30*h+0.5*m-6*m);
  if(deg>180){
    deg = 360-deg;
  }
  c=sqrtl(a*a+b*b-2*a*b*cosl(deg*3.14159265/180));
  printf("%lf\n", c);
  return 0;
}
