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