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

int main()
{
  int a,b,h,m;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&h);
  scanf("%d",&m);

  printf("%f",(double)sqrt(hypot(a,b)-2*a*b*cos(30*h-6*m));
  return 0;
}