#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653
int main(){
  double a,b,h,m;
  scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
  double angle = fabs((60*h-11*m)/2);
  double c = sqrt(a*a + b*b - 2*a*b*cos(angle * PI / 180));
  printf("%lf\n", c);
  return 0;
}
