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

double	mto2pi(int m)
{
  	return 3.141592653589793238 / 180 * m * 6;
}

double	hto2pi(int h, int m)
{
	return 3.141592653589793238 / 180 * (h * 30 + m / 2);
}

int main(void)
{
  	int a;
  	int b;
  	int h;
  	int m;
  	double	t;
  	double	l;
  
  	scanf("%d %d %d %d", &a, &b, &h, &m);
  
	t = hto2pi(h, m) - mto2pi(m);
  
  	l = sqrt((b - a * cos(t)) * (b - a * cos(t)) + (a * sin(t)) * (a * sin(t)));
  	printf("%lf", l);
  
  	return (0);
}

