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

int main(void){

	double a,b,h,m;
  scanf("%lf %lf %lf %lf", &a, &b, &h, &m);
	double a_deg = 2.0*M_PI*(h/12.0)+(1.0/6.0)*M_PI*(m/60.0);
	a_deg = (1.0/2.0)*M_PI-a_deg;
	double b_deg = 2.0*M_PI*(m/60.0);
	b_deg = (1.0/2.0)*M_PI-b_deg;
	double a_sin = a*sin(a_deg);
	double a_cos = a*cos(a_deg);
	double b_sin = b*sin(b_deg);
	double b_cos = b*cos(b_deg);
	double length = sqrt(pow(a_sin-b_sin,2)+pow(a_cos-b_cos,2));
	printf("%.12lf\n", length);

  return 0;
}