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