#include <stdio.h> 
#include <math.h>
#define pi 3.14159265358979323846
int main() {
  int a,b,h,m;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&h);
  scanf("%d",&m);
  double theta = fabs((double)h*120-(23*(double)m))*pi/720;
  double L;
  if (theta<=pi) L = sqrt(a*a+b*b-2*a*b*cos(theta));
  else L = sqrt(a*a+b*b+2*a*b*cos(theta));
  printf("%.10lf",L);
  return 0;
}