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

int main(void) 
{
  int a,b,h,m;
  scanf("%d %d %d %d",&a,&b,&h,&m);
  double scaler = 2 * M_PI;
  double angle_h = (double)(h*60+m)/720 * scaler;
  double angle_m = (double)m/60 * scaler;
  double angle = fabs(angle_h - angle_m) ;
  angle = (360 - angle < angle) ? 360 - angle : angle;
  double distance = sqrt(a*a+b*b-2*a*b*cos(angle));
  printf("%.15lf\n",distance);
  return 0;
}