#include <stdio.h>
#include <math.h>
void main()
{
  int a,b,h,m;
  double c;
  scanf("%d %d %d %d", &a, &b, &h, &m);
  double r;
  r = ((h/6.0) - (m/30.0))*M_PI;
  c = sqrt(a*a + b*b - 2*a*b*cos(r));
  printf("%f\n", c);
}