#include <stdio.h>
#include <float.h>
#include <math.h>
int main(void)
  
{
  int a,b,h,m;
  double n,x;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &h);
  scanf("%d", &m);
  n = (h * 60 + m) * 5.5;
  x = sqrt(a * a + b * b - 2 * a * b * cos(n * M_PI / 180));
  printf("%.15f", x);
return 0;
}